1- using ArgParse
21
32
43
54
65
6+ #=
7+ using ArgParse
78function parse_commandline_make_manifest_solar()
89 s = ArgParseSettings( description = "Make manifest.csv from FITS files in inputdir.")
910 @add_arg_table! s begin
@@ -35,23 +36,19 @@ function parse_commandline_make_manifest_solar()
3536 "--create-continuum"
3637 help = "Create missing continuum files"
3738 action = :store_true
39+ "--calc_order_snr"
40+ help = "Calculate order SNRs"
41+ action = :store_false
3842 "--verbose"
3943 help = "Verbose outputs"
4044 action = :store_true
4145 end
4246
4347 return parse_args(s)
4448end
45- args = parse_commandline_make_manifest_solar ()
46- if haskey (args," root" ) root_dir = args[" root" ] end
47- if haskey (args," input" ) input_dir = args[" input" ] end
48- if haskey (args," output" ) output_dir = args[" output" ] end
49- if haskey (args," subdir" ) subdir = args[" subdir" ] end
50- # if haskey(args,"pyrohelio") pyrohelio_dir = args["pyrohelio"] end
51- if haskey (args," pyrheliometer" ) pyrheliometer_dir = args[" pyrheliometer" ] end
52- create_missing_continuum_files = haskey (args," create-continuum" ) ? args[" create-continuum" ] : false
53- verbose = haskey (args," verbose" ) ? args[" verbose" ] : false
49+ =#
5450
51+ verbose = false
5552if verbose && ! isdefined (Main,:RvSpectML ) println (" # Loading RvSpecML" ) end
5653 using RvSpectMLBase
5754 using EchelleInstruments, EchelleInstruments. NEID
@@ -63,8 +60,19 @@ if verbose && !isdefined(Main,:RvSpectML) println("# Loading RvSpecML") end
6360 using SunAsAStar. DifferentialExtinction
6461 if verbose println (" # Loading other packages" ) end
6562 using CSV, DataFrames, Query, Dates
63+ using NaNMath
6664 # using StatsBase, Statistics, Dates
6765
66+ args = parse_commandline_make_manifest_solar ()
67+ if haskey (args," root" ) root_dir = args[" root" ] end
68+ if haskey (args," input" ) input_dir = args[" input" ] end
69+ if haskey (args," output" ) output_dir = args[" output" ] end
70+ if haskey (args," subdir" ) subdir = args[" subdir" ] end
71+ # if haskey(args,"pyrohelio") pyrohelio_dir = args["pyrohelio"] end
72+ if haskey (args," pyrheliometer" ) pyrheliometer_dir = args[" pyrheliometer" ] end
73+ create_missing_continuum_files = haskey (args," create-continuum" ) ? args[" create-continuum" ] : false
74+ calc_order_snr = haskey (args," calc_order_snr" ) ? args[" calc_order_snr" ] : false
75+ verbose = haskey (args," verbose" ) ? args[" verbose" ] : false
6876
6977fits_target_str = " Sun"
7078 paths_to_search_for_param = [pwd (),pkgdir (NeidSolarScripts)]
@@ -275,11 +283,11 @@ if verbose println("# Reading in customized parameters from param.jl.") end
275283=#
276284
277285
278- # using NaNMath
279- compute_order_snr = false
280- if compute_order_snr
281- println (" # Computing order SNRs" )
282- df_files_use[! ,:order_snrs ] = fill (zeros (0 ),size (df_files_use,1 ))
286+ try
287+ # using NaNMath # Uncommented
288+ if calc_order_snr
289+ println (" # Computing all order SNRs" )
290+ df_files_use[! ,:order_snrs ] = fill (zeros (0 ),size (df_files_use,1 ))
283291 for (i,row) in enumerate (eachrow (df_files_use))
284292 # if row.target != "Sun" continue end
285293 if any (map (ss-> contains (row. target,ss),calibration_target_substrings))
@@ -292,6 +300,24 @@ df_files_use[!,:order_snrs] = fill(zeros(0),size(df_files_use,1))
292300 order_snr = map (ord-> RvSpectMLBase. calc_snr (spec, pixels, ord), all_orders)
293301 df_files_use[i,:order_snrs ] = order_snr
294302 end
303+ else
304+ println (" # Computing order 98 SNR" )
305+ df_files_use[! ,:snr_order_98 ] = zeros (size (df_files_use,1 ))
306+ for (i,row) in enumerate (eachrow (df_files_use))
307+ # if row.target != "Sun" continue end
308+ if any (map (ss-> contains (row. target,ss),calibration_target_substrings))
309+ println (" # Warning: target = " , row. target)
310+ continue
311+ end
312+ spec = NEID. read_data (row)
313+ order_idx = 76 # physical order 98
314+ pixels = get_pixel_range (NEID2D (),order_idx)
315+ order_snr = RvSpectMLBase. calc_snr (spec, pixels, order_idx)
316+ df_files_use[i,:snr_order_98 ] = order_snr
317+ end
318+ end
319+ catch
320+ @warn (" Error computing order SNR." )
295321end
296322
297323println (" # Writing manifest file." )
0 commit comments