inmaputil

package
v1.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2022 License: GPL-3.0 Imports: 38 Imported by: 1

Documentation

Overview

Package inmaputil contains configuration and utility functions for commonly-used operations with the InMAP model.

Index

Constants

This section is empty.

Variables

View Source
var DefaultScienceFuncs = []inmap.CellManipulator{
	inmap.UpwindAdvection(),
	inmap.Mixing(),
	inmap.MeanderMixing(),
	scienceMust(m.DryDep("simple")),
	scienceMust(m.WetDep("emep")),
	m.Chemistry(),
}

DefaultScienceFuncs are the science functions that are run in typical simulations.

Functions

func CleanSR added in v1.5.0

func CleanSR(ctx context.Context, jobName, VariableGridData string, VarGrid *inmap.VarGridConfig, begin, end int, layers []int, client cloudrpc.CloudRPCClient) error

CleanSR cleans up remote data created during the SR matrix creation simulations.

func CloudJobDelete added in v1.5.0

func CloudJobDelete(ctx context.Context, name string, c cloudrpc.CloudRPCClient) error

CloudJobDelete deletes the specified cloud job.

func CloudJobOutput added in v1.5.0

func CloudJobOutput(ctx context.Context, c cloudrpc.CloudRPCClient, cfg *Cfg) error

CloudJobOutput retrieves and saves the output of a cloud job based on the information in cfg. The files will be saved in `current_dir/job_name`, where current_dir is the directory the command is run in.

func CloudJobStart added in v1.5.0

func CloudJobStart(ctx context.Context, c cloudrpc.CloudRPCClient, cfg *Cfg) error

CloudJobStart starts a new cloud job based on the information in cfg.

func CloudJobStatus added in v1.5.0

func CloudJobStatus(ctx context.Context, c cloudrpc.CloudRPCClient, cfg *Cfg) (*cloudrpc.JobStatus, error)

CloudJobStatus checks the status of a cloud job based on the information in cfg.

func GetStringMapString

func GetStringMapString(varName string, cfg *viper.Viper) map[string]string

GetStringMapString returns a map[string]string from a viper configuration, accounting for the fact that it might be a json object if it was set from a command line argument.

func Grid

func Grid(InMAPData, VariableGridData string, VarGrid *inmap.VarGridConfig) error

Grid creates and saves a new variable resolution grid.

InMAPData is the path to location of baseline meteorology and pollutant data. The path can include environment variables.

VariableGridData is the path to the location where the variable-resolution gridded InMAP data should be created.

VarGrid provides information for specifying the variable resolution grid.

func IsBlob added in v1.5.0

func IsBlob(path string) bool

IsBlob returns whether the given filename represents a blob. (i.e., if it starts with `gs://`, 's3://', or 'file://').

func NewCloudClient added in v1.5.0

func NewCloudClient(cfg *Cfg) (cloudrpc.CloudRPCClient, error)

NewCloudClient creates a new RPC client based on the information in cfg.

func Preproc

func Preproc(StartDate, EndDate, CTMType, WRFOut, GEOSA1, GEOSA3Cld, GEOSA3Dyn, GEOSI3, GEOSA3MstE, GEOSApBp,
	GEOSChem, OlsonLandMap, InMAPData string, CtmGridXo, CtmGridYo, CtmGridDx, CtmGridDy float64, dash bool, recordDeltaStr, fileDeltaStr string, noChemHour bool) error

Preproc preprocesses chemical transport model output as specified by information in cfg and saves the result for use in future InMAP simulations.

StartDate is the date of the beginning of the simulation. Format = "YYYYMMDD".

EndDate is the date of the end of the simulation. Format = "YYYYMMDD".

CTMType specifies what type of chemical transport model we are going to be reading data from. Valid options are "GEOS-Chem" and "WRF-Chem".

WRFOut is the location of WRF-Chem output files. [DATE] should be used as a wild card for the simulation date.

GEOSA1 is the location of the GEOS 1-hour time average files. [DATE] should be used as a wild card for the simulation date.

GEOSA3Cld is the location of the GEOS 3-hour average cloud parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSA3Dyn is the location of the GEOS 3-hour average dynamical parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSI3 is the location of the GEOS 3-hour instantaneous parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSA3MstE is the location of the GEOS 3-hour average moist parameters on level edges files. [DATE] should be used as a wild card for the simulation date.

GEOSApBp is the location of the pressure level variable file. It is optional; if it is not specified the Ap and Bp information will be extracted from the GEOSChem files.

GEOSChem is the location of GEOS-Chem output files. [DATE] should be used as a wild card for the simulation date.

OlsonLandMap is the location of the GEOS-Chem Olson land use map file, which is described here: http://wiki.seas.harvard.edu/geos-chem/index.php/Olson_land_map

InMAPData is the path where the preprocessed baseline meteorology and pollutant data should be written.

CtmGridXo is the lower left of Chemical Transport Model (CTM) grid [x].

CtmGridYo is the lower left of grid [y]

CtmGridDx is the grid cell size in the x direction [m].

CtmGridDy is the grid cell size in the y direction [m].

dash indicates whether GEOS-Chem variable names are in the form 'IJ-AVG-S__xxx' as opposed to 'IJ_AVG_S_xxx'.

func Run

func Run(CobraCommand *cobra.Command, LogFile string, OutputFile string, OutputAllLayers bool, OutputVariables map[string]string,
	EmissionUnits string, EmissionsShapefiles []string, EmissionsMask geom.Polygon, VarGrid *inmap.VarGridConfig,
	inventoryConfig *aeputil.InventoryConfig, spatialConfig *aeputil.SpatialConfig,
	InMAPData, VariableGridData string, NumIterations int,
	dynamic, createGrid bool, scienceFuncs []inmap.CellManipulator, addInit, addRun, addCleanup []inmap.DomainManipulator,
	m inmap.Mechanism) error

Run runs the model. dynamic and createGrid specify whether the variable resolution grid should be created dynamically and whether the static grid should be created or read from a file, respectively.

CobraCommand is the cobra.Command instance where Run is called from. It is needed to print certain outputs to the web interface.

LogFile is the path to the desired logfile location. It can include environment variables.

OutputFile is the path to the desired output shapefile location. It can include environment variables.

If OutputAllLayers is true, output data for all model layers. If false, only output the lowest layer.

OutputVariables specifies which model variables should be included in the output file.

EmissionUnits gives the units that the input emissions are in. Acceptable values are 'tons/year', 'kg/year', 'ug/s', and 'μg/s'.

EmissionsShapefiles are the paths to any emissions shapefiles. Can be elevated or ground level; elevated files need to have columns labeled "height", "diam", "temp", and "velocity" containing stack information in units of m, m, K, and m/s, respectively. Emissions will be allocated from the geometries in the shape file to the InMAP computational grid, but the mapping projection of the shapefile must be the same as the projection InMAP uses.

EmissionsMask specifies a polygon boundary to constrain emissions, assumed to use the same spatial reference as VarGrid. It will be ignored if it is nil.

VarGrid provides information for specifying the variable resolution grid.

InMAPData is the path to location of baseline meteorology and pollutant data.

VariableGridData is the path to the location of the variable-resolution gridded InMAP data, or the location where it should be created if it doesn't already exist.

NumIterations is the number of iterations to calculate. If < 1, convergence is automatically calculated.

If dynamic is true, createGrid is ignored. scienceFuncs specifies the science functions to perform in each cell at each time step. addInit, addRun, and addCleanup specifies functions beyond the default functions to run at initialization, runtime, and cleanup, respectively.

notMeters should be set to true if the units of the grid are not meters (e.g., if the grid is in degrees latitude/longitude.)

func SRPredict

func SRPredict(EmissionUnits, SROutputFile, OutputFile string, outputVariables map[string]string, EmissionsShapefiles []string, emissionMask geom.Polygon, VarGrid *inmap.VarGridConfig) error

SRPredict uses the SR matrix specified in SROutputFile to predict concentrations resulting from the emissions in EmissionsShapefiles (optionally masked by emissionMask), outputting the results specified by outputVaraibles in OutputFile. EmissionUnits specifies the units of the emissions. VarGrid specifies the variable resolution grid.

func SaveSR added in v1.5.0

func SaveSR(ctx context.Context, jobName, OutputFile string, VariableGridData string, VarGrid *inmap.VarGridConfig, begin, end int, layers []int, client cloudrpc.CloudRPCClient) error

SaveSR saves the SR matrix results to an output file.

jobName is a user-specified name for the SR creation job.

VariableGridData is the path to the location of the variable-resolution gridded InMAP data.

OutputFile is the path where the output file is or should be created when creating a source-receptor matrix.

VarGrid provides information for specifying the variable resolution grid.

begin and end specify the beginning and end grid indices to save.

layers specifies which vertical layers to save.

client is a client of the cluster that will run the simulations.

func StartSR added in v1.5.0

func StartSR(ctx context.Context, jobName string, cmds []string, memoryGB int32, VariableGridData string, VarGrid *inmap.VarGridConfig, begin, end int, layers []int, client cloudrpc.CloudRPCClient, cfg *Cfg) error

StartSR starts the SR matrix creator, getting configuration information from the global Cfg variable.

jobName is a user-specified name for the SR creation job.

cmds is a list of InMAP subcommands for the individual simulations.

memoryGB is the RAM required for each simulation, in GB.

VariableGridData is the path to the location of the variable-resolution gridded InMAP data.

VarGrid provides information for specifying the variable resolution grid.

begin and end specify the beginning and end grid indices to process.

layers specifies which vertical layers to process.

client is a client of the cluster that will run the simulations.

func VarGridConfig

func VarGridConfig(cfg *viper.Viper) (*inmap.VarGridConfig, error)

VarGridConfig unmarshals a viper configuration for a variable grid.

Types

type Cfg

type Cfg struct {
	*viper.Viper

	Root *cobra.Command
	// contains filtered or unexported fields
}

Cfg holds configuration information.

func InitializeConfig added in v1.5.0

func InitializeConfig() *Cfg

func (*Cfg) InputFiles added in v1.5.0

func (cfg *Cfg) InputFiles() []string

InputFiles returns the names of the configuration options that are input files.

func (*Cfg) OutputFiles added in v1.5.0

func (cfg *Cfg) OutputFiles() []string

OutputFiles returns the names of the configuration options that are output files.

func (*Cfg) StartWebServer added in v1.5.0

func (cfg *Cfg) StartWebServer()

StartWebServer starts the web server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL