Skip to content

Commit 2ed1977

Browse files
committed
separate pipeline into smaller steps
1 parent 1b42c67 commit 2ed1977

File tree

4 files changed

+562
-29
lines changed

4 files changed

+562
-29
lines changed

examples/calc_order_ccfs_using_continuum_1.1.jl

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,30 @@ println("# Parsing arguments...")
147147
"--max_solar_hour_angle"
148148
help = "Maximum absolute value of solar hour angle."
149149
arg_type = Float64
150-
default = 6.0
150+
default = 3.12
151+
"--max_solar_hour_angle_clean"
152+
help = "Maximum absolute value of solar hour angle for clean spectrum."
153+
arg_type = Float64
154+
default = 2.0
151155
"--max_airmass"
152156
help = "Maximum airmass."
153157
arg_type = Float64
154-
#default = 10.0
158+
"--max_airmass_clean"
159+
help = "Maximum airmass for clean spectrum."
160+
arg_type = Float64
161+
default = 2.0
162+
#=
155163
"--min_snr_factor"
156164
help = "Minimum SNR relative to max_snr."
157165
arg_type = Float64
158-
#default = 0.0
166+
"--min_snr_factor_clean"
167+
help = "Minimum SNR relative to max_snr for clean spectrum."
168+
arg_type = Float64
169+
default = 0.5
159170
"--max_snr"
160171
help = "Specify max_snr manually."
161172
arg_type = Float64
173+
=#
162174
"--start_time"
163175
help = "Specify daily start time for CCFs to be processed (HH MM)"
164176
nargs = 2
@@ -175,7 +187,11 @@ println("# Parsing arguments...")
175187
"--max_num_spectra"
176188
help = "Maximum number of spectra to process."
177189
arg_type = Int
178-
default = 250 # TODO: Increase after finish testing
190+
default = 300 # Enough for one day of NEID
191+
"--max_num_spectra_clean"
192+
help = "Maximum number of spectra to include in clean spectrum."
193+
arg_type = Int
194+
default = 65 # based on 60 minutes of integration time from 55s exposures
179195
end
180196

181197
return parse_args(s)
@@ -310,7 +326,9 @@ if verbose println("# Reading manifest of files to process.") end
310326
if args["target"] == "Sun" || args["target"] == "Solar"
311327
@assert hasproperty(df_files,:alt_sun) # TODO: Compute if not avaliable?
312328
@assert hasproperty(df_files,:Δfwhm²) # TODO: Compute if not avaliable?
313-
df_files[!,"solar_hour_angle"] = SolarRotation.get_solar_hour_angle(df_files.bjd,obs=:WIYN)
329+
if !hasproperty(df_files,:solar_hour_angle)
330+
df_files[!,"solar_hour_angle"] = SolarRotation.get_solar_hour_angle(df_files.bjd,obs=:WIYN)
331+
end
314332
#if eltype(df_files[!,:order_snrs]) == String # TODO: Compute if not avaliable?
315333
end
316334
#=
@@ -332,7 +350,7 @@ if verbose println("# Reading manifest of files to process.") end
332350
=#
333351

334352
@assert args["max_airmass"] == nothing || 1 < args["max_airmass"] <= 10 # not tested beyond 10
335-
@assert args["min_snr_factor"] == nothing || 0 <= args["min_snr_factor"] < 1
353+
#@assert args["min_snr_factor"] == nothing || 0 <= args["min_snr_factor"] < 1
336354
@assert args["max_solar_hour_angle"] == nothing || 0 < args["max_solar_hour_angle"] <= 6
337355

338356
min_drp_minor_version = VersionNumber(1,1,0)
@@ -341,15 +359,42 @@ if verbose println("# Reading manifest of files to process.") end
341359

342360
df_files_use = df_files |>
343361
@filter( args["target"] == nothing || _.target == args["target"] ) |>
362+
DataFrame
363+
df_files_use = df_files_use |>
344364
@filter( args["datestr"] == nothing || occursin(args["datestr"],_.target) ) |>
365+
DataFrame
366+
df_files_use = df_files_use |>
345367
@filter( args["max_airmass"] == nothing || _.airmass <= args["max_airmass"] ) |>
368+
DataFrame
369+
df_files_use = df_files_use |>
346370
@filter( args["max_solar_hour_angle"] == nothing || abs(_.solar_hour_angle) <= args["max_solar_hour_angle"] ) |>
371+
DataFrame
372+
df_files_use = df_files_use |>
347373
@filter( args["start_time"] == nothing || Time(julian2datetime(_.bjd)) >= start_time ) |>
374+
DataFrame
375+
df_files_use = df_files_use |>
348376
@filter( args["stop_time"] == nothing || Time(julian2datetime(_.bjd)) <= stop_time ) |> # TODO for other instruments may need to deal wtih cross end of 24 UTC
377+
DataFrame
378+
df_files_use = df_files_use |>
349379
@filter( _.drpversion != "" && (min_drp_minor_version <= Base.thisminor(VersionNumber(_.drpversion)) <= max_drp_minor_version )) |>
350-
# TODO: Replace to use expmeter or pyrheliometer data
380+
DataFrame
351381
# @filter( args["min_snr_factor"] == nothing || sum(_.order_snrs) >= args["min_snr_factor"] * max_snr ) |>
352-
@take(args["max_num_spectra"] ) |> @orderby(_.bjd) |>
382+
# TODO: Replace to use expmeter or pyrheliometer data
383+
if !hasproperty(df_files_use,:mean_pyroflux) || !hasproperty(df_files_use,:rms_pyroflux) || any(ismissing.(df_files_use.mean_pyroflux)) || any(ismissing.(df_files_use.rms_pyroflux))
384+
@error "Manifest file doesn't include valid mean_pyroflux and/or rms_pyroflux." manifest_filename
385+
end
386+
df_files_use = df_files_use |>
387+
@filter( _.rms_pyroflux <= 0.0035* _.mean_pyroflux ) |>
388+
DataFrame
389+
df_files_use = df_files_use |>
390+
@filter( _.expmeter_mean >= 6e4 ) |>
391+
DataFrame
392+
df_files_use = df_files_use |>
393+
@filter( _.driftfun == "dailymodel0" ) |>
394+
DataFrame
395+
df_files_use = df_files_use |>
396+
@orderby(_.bjd) |>
397+
@take(args["max_num_spectra"] ) |>
353398
DataFrame
354399
println("# Found ", size(df_files_use,1), " files of ", size(df_files,1), " to process.")
355400
if !(size(df_files_use,1) >= 1)
@@ -362,10 +407,11 @@ if verbose println("# Reading manifest of files to process.") end
362407

363408
df_files_cleanest = df_files_use |>
364409
@filter( min_drp_minor_version <= Base.thisminor(VersionNumber(_.drpversion)) <= max_drp_minor_version ) |>
365-
@filter( _.airmass <= 2.0 ) |>
366-
@filter( abs(_.solar_hour_angle) <= 1 ) |>
367-
#@filter( sum(_.order_snrs) >= 0.9 * max_snr ) |>
368-
@take(args["max_num_spectra"] ) |>
410+
#@filter( _.airmass <= 2.0 ) |>
411+
@filter( _.airmass <= args["max_airmass_clean"] ) |>
412+
@filter( abs(_.solar_hour_angle) <= args["max_solar_hour_angle_clean"] ) |>
413+
@orderby( abs(_.solar_hour_angle) ) |>
414+
@take(args["max_num_spectra_clean"] ) |>
369415
DataFrame
370416
println("# Found ", size(df_files_cleanest,1), " files considered clean.")
371417
#@assert size(df_files_cleanest,1) >= 1

examples/combine_daily_reports_v1.0.jl

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ using ArgParse
1414
"output"
1515
help = "Filename for output (csv)"
1616
arg_type = String
17-
default = "monthly_rvs.csv"
17+
default = "summary.csv"
1818
"--input_filename"
1919
help = "Filename for daily reports (toml)"
2020
arg_type = String
21-
default = "daily_summary_1.toml"
21+
default = "daily_summary.toml"
2222
"--overwrite"
2323
help = "Specify it's ok to overwrite the output file."
2424
#default = true
@@ -42,13 +42,13 @@ using ArgParse
4242

4343
input_fn = args["input_filename"]
4444
input_path = args["input_path"]
45-
output_fn = args["output"]
45+
output_fn = joinpath(input_path,args["output"])
4646

47-
if !(args["overwrite"] || !isfile(args["output"]) || (filesize(args["output"])==0))
48-
@error "Can't overwrite " output_filename=args["output"]
47+
if !(args["overwrite"] || !isfile(output_fn) || (filesize(output_fn)==0))
48+
@error "Can't overwrite " output_filename=output_fn
4949
exit(1)
5050
else
51-
#touch(args["output"]) # Should we create empty file as a lock?
51+
#touch(output_fn) # Should we create empty file as a lock?
5252
end
5353

5454
@info "# Loading packages"
@@ -92,16 +92,6 @@ df.winsor_rms_rv_drp = map(day->day["rv"]["drp"]["winsor_rms_rv"], daily)
9292
df_sorted = df |> @orderby( _.mean_bjd ) |> DataFrame
9393

9494
@info "# Writing CSV file"
95-
CSV.write(args["output"],df_sorted )
95+
CSV.write(output_fn,df_sorted )
9696

97-
#=
98-
julia> d
99-
Dict{String, Any} with 5 entries:
100-
"obs_date" => Dict{String, Any}("string"=>Date("2021-12-20"), "mean_bjd"=>2.45957e6)
101-
"rv" => Dict{String, Any}("drp"=>Dict{String, Any}("mean_rv"=>-0.638301, "winsor_rms_rv"=>7.7872e-5, "median_rv"=>-0.638253, "median_σ_rv…
102-
"report" => Dict{String, Any}("input_md5"=>"649267d306710ca1883be5994954fbc1", "date_run"=>DateTime("2021-12-23T20:47:55.700"), "hostname"=>"…
103-
"num_rvs" => Dict{String, Any}("usable"=>114, "good"=>114)
104-
"title" => "NEID Solar Observations Daily Report"
105-
106-
=#
10797

0 commit comments

Comments
 (0)