Skip to content

Commit dd39b7f

Browse files
committed
protect empty manifest
1 parent b964fa1 commit dd39b7f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

scripts/make_pyrheliometer_daily_1.1.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,29 @@ else
9292
if hasproperty(df_in, :l1filename) df_in = df_in |> @rename(:l1filename => :Filename) |> DataFrame end
9393
if hasproperty(df_in, :l2filename) df_in = df_in |> @rename(:l2filename => :Filename) |> DataFrame end
9494
if hasproperty(df_in, :filename) df_in = df_in |> @rename(:filename => :Filename) |> DataFrame end
95-
target_datestr = nothing
96-
target_date = nothing
95+
m = match(r"(\d{4})\/(\d{2})\/(\d{2})\/",manifest_fn)
96+
if isnothing(m) || (length(m.captures) != 3)
97+
target_datestr = nothing
98+
target_date = nothing
99+
println("# Empty ", manifest_fn, " and can't figure out date to query. Giving up.")
100+
error(0)
101+
else
102+
@assert length(m.captures) == 3
103+
year = parse(Int64,m[1])
104+
month = parse(Int64,m[2])
105+
day = parse(Int64,m[3])
106+
@assert 2020 <= year <= 2040
107+
@assert 1 <= month <= 12
108+
@assert 1 <= day <= 31
109+
target_datestr = args["manifest_or_date"]
110+
target_date = Date(m[1]*m[2]*m[3],DateFormat("yyyymmdd"))
111+
end
97112
end
98113

99114
using TOML
100115
using NeidArchive
101116

102-
if size(df_in,1) == 0
117+
if (size(df_in,1) == 0) && (!isnothing(target_date))
103118
if isnothing(args["user"]) || isnothing(args["password"])
104119
nexsci_dict = TOML.parsefile(nexsci_login_fn)
105120
user_nexsci = nexsci_dict["user"]

0 commit comments

Comments
 (0)