@@ -45,6 +45,9 @@ function parse_commandline_make_pyrheliometer_daily()
4545 help = " Path to root of data directories"
4646 arg_type = String
4747 default = " "
48+ " --try_tel_first"
49+ help = " Try pyrheliometer telemetry file before L0s"
50+ action = :store_true
4851 " --verbose"
4952 help = " Verbose outputs"
5053 action = :store_true
@@ -128,26 +131,36 @@ if size(df_in,1) == 0
128131 df_in = df_in |> @rename (:l0filename => :Filename ) |> DataFrame
129132end
130133
131- if ! isnothing (pyrohelio_dir) && isdir (pyrohelio_dir)
134+ if args[ " try_tel_first " ] && ( ! isnothing (pyrohelio_dir) && isdir (pyrohelio_dir) )
132135 pyrohelio_files = Pyroheliometer. make_pyrohelio_file_dataframe (pyrohelio_dir)
133136 @assert hasproperty (df_in," Filename" )
134137 @assert hasproperty (df_in," exptime" )
135138 df_out = DataFrame (map (r-> Pyroheliometer. get_pyrohelio_summary (pyrohelio_files, string (r. Filename), r. exptime), eachrow (df_in)))
139+ else
140+ pyrohelio_files = DataFrame ()
141+ df_out = DataFrame ()
136142end
137143
138- if isnothing (pyrohelio_dir) || ! isdir (pyrohelio_dir ) || any (ismissing .(df_out. mean_pyroflux))
144+ if ( size (df_out, 1 ) == 0 ) || any (ismissing .(df_out. mean_pyroflux))
139145 if ! isdir (tmp_path) mkpath (tmp_path) end
140- pyrohelio_files = DataFrame ()
141146 # println("# start_row = ", 1, " end_row = ", num_lines-1)
142147 # NeidArchive.download(query_fn, param["datalevel"], outdir=tmp_path, cookiepath=cookie_fn, start_row=1, end_row=10)
143148 # NeidArchive.download(query_fn, "l0", outdir=tmp_path, cookiepath=cookie_fn, start_row=1, end_row=10)
144149 # NeidArchive.download(query_fn, "l0", outdir=tmp_path, cookiepath=cookie_fn)
145150 df_out = DataFrame (map (fn-> Pyroheliometer. get_pyrohelio_summary (joinpath (tmp_path,replace (string (fn)," neidL2_" => " neidL0_" ))),df_in. Filename))
146151end
147152
153+ if (size (df_out,1 ) == 0 ) && ! args[" try_tel_first" ] && (! isnothing (pyrohelio_dir) && isdir (pyrohelio_dir))
154+ pyrohelio_files = Pyroheliometer. make_pyrohelio_file_dataframe (pyrohelio_dir)
155+ @assert hasproperty (df_in," Filename" )
156+ @assert hasproperty (df_in," exptime" )
157+ df_out = DataFrame (map (r-> Pyroheliometer. get_pyrohelio_summary (pyrohelio_files, string (r. Filename), r. exptime), eachrow (df_in)))
158+ end
159+
160+
148161CSV. write (output_fn, df_out)
149162df_to_rm = df_in |> @filter ( occursin (r" neidL0_\d {8}T\d +\. fits" ,_. Filename) ) |> @select (:Filename ) |> @filter (isfile (_. Filename)) |> DataFrame
150- map (fn-> println (" rm $fn " ),df_to_rm. Filename)
163+ # map(fn->println("rm $fn"),df_to_rm.Filename)
151164exit (0 )
152165
153166#=
0 commit comments