stilt.migration.import_stilt_r#
- stilt.migration.import_stilt_r(by_id_dir, output_dir, version, *, name='stilt-r', smooth_factor=None, met_path=None)[source]#
Write the runs of a STILT-R or X-STILT
by-idfolder into a PYSTILT output directory.Each run’s particles and footprint, as
read_stilt_r()reads them, go to the folders of a variant withmodel: stilt-r(StiltRModel). A project whoseconfig.yamlhas that variant reads them as its own results:project.status,project.particles,project.footprints, andproject.jacobian. The import prints the variant and its met, to paste intoconfig.yaml, and returns the receptors, forreceptors.csv.Every folder of an output directory is named by the hash of its settings, and an imported run’s settings are only what STILT-R’s files record, never a default standing in for a value they do not give:
HYSPLIT’s settings from each run’s
SETUP.CFG;n_hours,w_option,z_top, andemisshrsfrom itsCONTROL; andziscalefrom itsZICONTROLfile whenSETUP.CFGsays STILT-R wrote one (ZICONTROLTF), else 1 (no scaling).hnf_plumefrom the particles: STILT-R’s near-field correction adds thefoot_no_hnf_dilutioncolumn.The met: the directory the
CONTROLfiles name, as they name it. Each run’s met files are recorded in its particle file, and need not exist any more.The footprint’s grid and
time_integratefrom<id>_foot.nc, and itssmooth_factorfromparams.RDSor smooth_factor, asread_stilt_r()reads them.The STILT-R version, which no file records: version.
The second set of particles of a run with transport error (
particle_error) goes to the folder of a second variant,<name>-err, with the wind and mixed-layer error settings STILT-R saved with it (particle_error_params). It has particles only: STILT-R makes no footprint of them. A run whosestilt.logsays that no particle reached the footprint grid gets an empty footprint, as a PYSTILT run would. Results already in the output directory are kept, so an import can be run again after more STILT-R runs finish.- Parameters:
by_id_dir (
str|Path) – Theby-idfolder, such asmy_project/out/by-id.output_dir (
str|Path) – The output directory, asoutput:inconfig.yamlnames it.version (
str) – The STILT-R version that made the runs, such as the commit of uataq/stilt the project was made from (git rev-parse --short HEADin a STILT-R project folder).name (
str) – Name of the variant and of its met. The transport-error variant is<name>-err.smooth_factor (
float|None) – Thesmooth_factorSTILT-R made the footprints with, for a project withoutparams.RDS, as forread_stilt_r().met_path (
str|None) – The met directory to record when theCONTROLfiles name more than one, such as STILT-R’smet_pathwith its files in yearly folders. Every directory they name must be in it.
- Returns:
The receptors of the runs, in folder order, for
stilt.Project.add_receptors().- Return type:
list[stilt.receptor.Receptor]- Raises:
ImportError – If the rdata package is not installed.
FileNotFoundError – As
read_stilt_r()raises it, or if a run has noSETUP.CFGor noZICONTROLfile that itsSETUP.CFGsays it has.ValueError – As
read_stilt_r()raises it, or if name is not a variant name; if two runs were made with different settings, which is said by name (import each set from aby-idfolder of its own, under a name of its own); ifSETUP.CFGholds a setting PYSTILT does not have, orKMSLother than 0 (heights above sea level); if theCONTROLfiles name several met directories and met_path is not given or does not hold them all; or ifSETUP.CFGand the.rdsdisagree on whether a run had transport error.
Examples
>>> receptors = stilt.migration.import_stilt_r( ... "my_project/out/by-id", "output", version="1d936c1" ... ) mets: stilt-r: met_path: /data/hrrr variants: stilt-r: model: stilt-r met: stilt-r version: 1d936c1 capemin: -1 ... >>> project = stilt.Project.init("my_project_py", receptors, output="output", ...)