TCCON / py-ginput

Public repository for the GINPUT priors generator
Apache License 2.0
0 stars 4 forks source link

Automation fails when longitude is slightly negative #5

Closed joshua-laughner closed 1 year ago

joshua-laughner commented 1 year ago

Some jobs submitted with the following inputs failed (email redacted):

site_id=np,uc,hf
start_date=20210423
end_date=20210731
lat=51.426,51.523,51.608
lon=-0.345,-0.132,0.175
email=******
mod_fmt=none
vmr_fmt=none
map_fmt=text

The error was:

Traceback (most recent call last):
  File "/home/tccon/AutoModRust/python/ginput/run_ginput.py", line 61, in <module>
    main()
  File "/home/tccon/AutoModRust/python/ginput/run_ginput.py", line 57, in main
    driver(**args)
  File "/home/tccon/AutoModRust/python/ginput/ginput/priors/automation.py", line 255, in job_driver
    _make_map_files(all_args)
  File "/home/tccon/AutoModRust/python/ginput/ginput/priors/automation.py", line 172, in _make_map_files
    vmrf = vmr_files[key]
KeyError: '2021073000_000W_51N'

Looking at the files produced for uc (the slightly west site):

$ find fpit/uc/ -type f
fpit/uc/vertical/FPIT_2021073000Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073003Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073006Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073009Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073012Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073015Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073018Z_52N_000W.mod
fpit/uc/vertical/FPIT_2021073021Z_52N_000W.mod
fpit/uc/vmrs-vertical/JL1_2021073000Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073003Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073006Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073009Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073012Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073015Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073018Z_52N_000E.vmr
fpit/uc/vmrs-vertical/JL1_2021073021Z_52N_000E.vmr

the .vmr files are named "000E" instead of the "000W" that the automation is looking for, so there is a mismatch in how rounding around 0 is handled.

joshua-laughner commented 1 year ago

Looking into this more thoroughly, I see that the .mod and .vmr files actually have different names: the .mod files use "000W" and the .vmr files use "000E". The .mod files generate the file name with mod_utils.mod_file_name and the .vmr files do so with mod_utils.vmr_file_name.

The issue is that we know the longitude when creating the .mod file, so it can correctly compute east vs. west. The .vmr file needs to use just the coordinate in the file name, which since it is 0, it assumes that the direction should be "east". The .mod files correctly match gsetup in that the coordinate should be west if the obs. longitude is at all < 0.

My fix for this was to change how ginput determines the output path for .vmr files; if it's given paths to .mod files, it uses the .mod file name directly, rather than recalculating it from the lat/lon. It falls back to that approach if given a data dictionary instead. This is implemented in commit 14b6fbe for v1.0.6 and 8aa57ff for the main branch.