Config Templating#650
Conversation
…d the ability to replace them
…vert an existing config
| ) | ||
|
|
||
| # Create a template version of the config | ||
| env.toTemplate( |
There was a problem hiding this comment.
This is great @jammont! It's nice that it's non-invasive and only adds useful functionality. The only comment/question I had: is it the case that the template files are always generated?
Would it be useful to have a flag to turn off/on this functionality? (who doesn't love more function arguments)
There was a problem hiding this comment.
This is automatic and cannot be disabled at this time. I figure the cost of the template files is insignificant and can be safely ignored. Having them auto-generated ensures that users that are unsure cannot mess-up and fail to provide them to us if they need assistance.
If we don't like them being generated side-by-side the source configs, we could create a new directory under the working_directory like debug or something to dump them to
…eplace a template config automatically
|
@jammont I tried again to get this to work with no luck. Does this only work with configs generated via apply_oe with this branch? I was attempting to use it to generate/rebuild template configs for a couple tests I'm trying to put together and the CLI commands were just returning the same input file. |
|
@jammont and I went back and forth and now I've gotten it to work locally, both Two thoughts:
|
Added new functionality to
ini.pyto convert to/from template configuration files which will make it easier to move a config from one system to another.toTemplateconverts an existing config file to a template version{env.[path]}, eg.{env.data},{env.examples}template_construction.pyauto does this now for presolve and full, creates the same config but with.tmplfromTemplateconverts a template config back using a different ini. The idea here is:apply_oe.pyfull.jsonandfull.json.tmplconfig files are generatedworking_directory(ie. output dir)working_directory, this is not found in the ini but is an additional replaceable item in the templateIf a given config is detected to be within a valid ISOFIT output directory then the
working_directorywill be auto-set. If not, the user will have to set it (such as the examples)isofit.pywill attempt to call thefromTemplatefunction if it detects an input config is a template version, and then use the converted returnAdditionally, added the above capabilities to our CLI:
isofit dev
isofit dev totmpl
isofit dev fromtmpl
Example
Trimmed the configs some so they're not so long
Working config generated by `template_construction.py`
{ "forward_model": { "instrument": { "integrations": 200, "parametric_noise_file": "/store/jamesmo/isofit/extras/data/emit_noise.txt", "unknowns": { "channelized_radiometric_uncertainty_file": "/local/jemit/data/channelized_uncertainty.txt", "uncorrelated_radiometric_uncertainty": 0.01 }, "wavelength_file": "/local/jemit/data/wavelengths.txt" }, "model_discrepancy_file": "/local/jemit/data/model_discrepancy.mat", "radiative_transfer": { "radiative_transfer_engines": { "vswir": { "aerosol_model_file": "/store/jamesmo/isofit/extras/data/aerosol_model.txt", "aerosol_template_file": "/store/jamesmo/isofit/extras/data/aerosol_template.json", "earth_sun_distance_file": "/store/jamesmo/isofit/extras/data/earth_sun_distance.txt", "emulator_aux_file": "/store/jamesmo/isofit/extras/srtmnet/sRTMnet_v120_aux.npz", "emulator_file": "/store/jamesmo/isofit/extras/srtmnet/sRTMnet_v120.h5", "engine_base_dir": "/store/jamesmo/isofit/extras/sixs", "engine_name": "sRTMnet", "glint_model": false, "interpolator_base_path": "/local/jemit/lut_full/sRTMnet_v120_vi", "irradiance_file": "/store/jamesmo/isofit/extras/examples/20151026_SantaMonica/data/prism_optimized_irr.dat", "lut_names": { "AOT550": null, "H2OSTR": null, "observer_zenith": null, "relative_azimuth": null, "surface_elevation_km": null }, "lut_path": "/local/jemit/lut_full/lut.nc", "multipart_transmittance": false, "sim_path": "/local/jemit/lut_full", "statevector_names": [ "H2OSTR", "surface_elevation_km", "AOT550" ], "template_file": "/local/jemit/config/emit20220820t131606_modtran_tpl.json" } }, }, "surface": { "select_on_init": true, "surface_category": "multicomponent_surface", "surface_file": "/local/jemit/data/surface.mat" } }, "input": { "loc_file": "/local/jemit/input/emit20220820t131606_subs_loc", "measured_radiance_file": "/local/jemit/input/emit20220820t131606_subs_rdn", "obs_file": "/local/jemit/input/emit20220820t131606_subs_obs" }, "output": { "atmospheric_coefficients_file": "/local/jemit/output/emit20220820t131606_subs_atm", "estimated_reflectance_file": "/local/jemit/output/emit20220820t131606_subs_rfl", "estimated_state_file": "/local/jemit/output/emit20220820t131606_subs_state", "posterior_uncertainty_file": "/local/jemit/output/emit20220820t131606_subs_uncert" } }Template config generated by `template_construction.py`
{ "forward_model": { "instrument": { "integrations": 200, "parametric_noise_file": "{env.data}/emit_noise.txt", "unknowns": { "channelized_radiometric_uncertainty_file": "{working_directory}/data/channelized_uncertainty.txt", "uncorrelated_radiometric_uncertainty": 0.01 }, "wavelength_file": "{working_directory}/data/wavelengths.txt" }, "model_discrepancy_file": "{working_directory}/data/model_discrepancy.mat", "radiative_transfer": { "radiative_transfer_engines": { "vswir": { "aerosol_model_file": "{env.data}/aerosol_model.txt", "aerosol_template_file": "{env.data}/aerosol_template.json", "earth_sun_distance_file": "{env.data}/earth_sun_distance.txt", "emulator_aux_file": "{env.srtmnet}/sRTMnet_v120_aux.npz", "emulator_file": "{env.srtmnet}/sRTMnet_v120.h5", "engine_base_dir": "{env.sixs}", "engine_name": "sRTMnet", "glint_model": false, "interpolator_base_path": "{working_directory}/lut_full/sRTMnet_v120_vi", "irradiance_file": "{env.examples}/20151026_SantaMonica/data/prism_optimized_irr.dat", "lut_names": { "AOT550": null, "H2OSTR": null, "observer_zenith": null, "relative_azimuth": null, "surface_elevation_km": null }, "lut_path": "{working_directory}/lut_full/lut.nc", "multipart_transmittance": false, "sim_path": "{working_directory}/lut_full", "statevector_names": [ "H2OSTR", "surface_elevation_km", "AOT550" ], "template_file": "{working_directory}/config/emit20220820t131606_modtran_tpl.json" } }, }, "surface": { "select_on_init": true, "surface_category": "multicomponent_surface", "surface_file": "{working_directory}/data/surface.mat" } }, "input": { "loc_file": "{working_directory}/input/emit20220820t131606_subs_loc", "measured_radiance_file": "{working_directory}/input/emit20220820t131606_subs_rdn", "obs_file": "{working_directory}/input/emit20220820t131606_subs_obs" }, "output": { "atmospheric_coefficients_file": "{working_directory}/output/emit20220820t131606_subs_atm", "estimated_reflectance_file": "{working_directory}/output/emit20220820t131606_subs_rfl", "estimated_state_file": "{working_directory}/output/emit20220820t131606_subs_state", "posterior_uncertainty_file": "{working_directory}/output/emit20220820t131606_subs_uncert" } }Template converted to my local Mac
Below commands generate the same thing
{ "forward_model": { "instrument": { "integrations": 200, "parametric_noise_file": "/Users/jamesmo/projects/isofit/extras/data/emit_noise.txt", "unknowns": { "channelized_radiometric_uncertainty_file": "/example/directory/replacement/data/channelized_uncertainty.txt", "uncorrelated_radiometric_uncertainty": 0.01 }, "wavelength_file": "/example/directory/replacement/data/wavelengths.txt" }, "model_discrepancy_file": "/example/directory/replacement/data/model_discrepancy.mat", "radiative_transfer": { "radiative_transfer_engines": { "vswir": { "aerosol_model_file": "/Users/jamesmo/projects/isofit/extras/data/aerosol_model.txt", "aerosol_template_file": "/Users/jamesmo/projects/isofit/extras/data/aerosol_template.json", "earth_sun_distance_file": "/Users/jamesmo/projects/isofit/extras/data/earth_sun_distance.txt", "emulator_aux_file": "/Users/jamesmo/projects/isofit/extras/srtmnet/sRTMnet_v120_aux.npz", "emulator_file": "/Users/jamesmo/projects/isofit/extras/srtmnet/sRTMnet_v120.h5", "engine_base_dir": "/Users/jamesmo/projects/isofit/extras/sixs", "engine_name": "sRTMnet", "glint_model": false, "interpolator_base_path": "/example/directory/replacement/lut_full/sRTMnet_v120_vi", "irradiance_file": "/Users/jamesmo/projects/isofit/extras/examples/20151026_SantaMonica/data/prism_optimized_irr.dat", "lut_names": { "AOT550": null, "H2OSTR": null, "observer_zenith": null, "relative_azimuth": null, "surface_elevation_km": null }, "lut_path": "/example/directory/replacement/lut_full/lut.nc", "multipart_transmittance": false, "sim_path": "/example/directory/replacement/lut_full", "statevector_names": [ "H2OSTR", "surface_elevation_km", "AOT550" ], "template_file": "/example/directory/replacement/config/emit20220820t131606_modtran_tpl.json" } }, }, "surface": { "select_on_init": true, "surface_category": "multicomponent_surface", "surface_file": "/example/directory/replacement/data/surface.mat" } }, "input": { "loc_file": "/example/directory/replacement/input/emit20220820t131606_subs_loc", "measured_radiance_file": "/example/directory/replacement/input/emit20220820t131606_subs_rdn", "obs_file": "/example/directory/replacement/input/emit20220820t131606_subs_obs" }, "output": { "atmospheric_coefficients_file": "/example/directory/replacement/output/emit20220820t131606_subs_atm", "estimated_reflectance_file": "/example/directory/replacement/output/emit20220820t131606_subs_rfl", "estimated_state_file": "/example/directory/replacement/output/emit20220820t131606_subs_state", "posterior_uncertainty_file": "/example/directory/replacement/output/emit20220820t131606_subs_uncert" } }