def __init__(self): model.InVESTModel.__init__( self, label=u'Scenic Quality', target=scenic_quality.execute, validator=scenic_quality.validate, localdoc=u'../documentation/scenic_quality.html') self.beta_only = inputs.Label( text=( u"This tool is considered UNSTABLE. Users may " u"experience performance issues and unexpected errors.")) self.general_tab = inputs.Container( interactive=True, label=u'General') self.add_input(self.general_tab) self.aoi_uri = inputs.File( args_key=u'aoi_uri', helptext=( u"An OGR-supported vector file. This AOI instructs " u"the model where to clip the input data and the extent " u"of analysis. Users will create a polygon feature " u"layer that defines their area of interest. The AOI " u"must intersect the Digital Elevation Model (DEM)."), label=u'Area of Interest (Vector)', validator=self.validator) self.general_tab.add_input(self.aoi_uri) self.cell_size = inputs.Text( args_key=u'cell_size', helptext=u'Length (in meters) of each side of the (square) cell.', label=u'Cell Size (meters)', validator=self.validator) self.general_tab.add_input(self.cell_size) self.structure_uri = inputs.File( args_key=u'structure_uri', helptext=( u"An OGR-supported vector file. The user must specify " u"a point feature layer that indicates locations of " u"objects that contribute to negative scenic quality, " u"such as aquaculture netpens or wave energy " u"facilities. In order for the viewshed analysis to " u"run correctly, the projection of this input must be " u"consistent with the project of the DEM input."), label=u'Features Impacting Scenic Quality (Vector)', validator=self.validator) self.general_tab.add_input(self.structure_uri) self.dem_uri = inputs.File( args_key=u'dem_uri', helptext=( u"A GDAL-supported raster file. An elevation raster " u"layer is required to conduct viewshed analysis. " u"Elevation data allows the model to determine areas " u"within the AOI's land-seascape where point features " u"contributing to negative scenic quality are visible."), label=u'Digital Elevation Model (Raster)', validator=self.validator) self.general_tab.add_input(self.dem_uri) self.refraction = inputs.Text( args_key=u'refraction', helptext=( u"The earth curvature correction option corrects for " u"the curvature of the earth and refraction of visible " u"light in air. Changes in air density curve the light " u"downward causing an observer to see further and the " u"earth to appear less curved. While the magnitude of " u"this effect varies with atmospheric conditions, a " u"standard rule of thumb is that refraction of visible " u"light reduces the apparent curvature of the earth by " u"one-seventh. By default, this model corrects for the " u"curvature of the earth and sets the refractivity " u"coefficient to 0.13."), label=u'Refractivity Coefficient', validator=self.validator) self.general_tab.add_input(self.refraction) self.pop_uri = inputs.File( args_key=u'pop_uri', helptext=( u"A GDAL-supported raster file. A population raster " u"layer is required to determine population within the " u"AOI's land-seascape where point features contributing " u"to negative scenic quality are visible and not " u"visible."), label=u'Population (Raster)', validator=self.validator) self.general_tab.add_input(self.pop_uri) self.overlap_uri = inputs.File( args_key=u'overlap_uri', helptext=( u"An OGR-supported vector file. The user has the " u"option of providing a polygon feature layer where " u"they would like to determine the impact of objects on " u"visual quality. This input must be a polygon and " u"projected in meters. The model will use this layer " u"to determine what percent of the total area of each " u"polygon feature can see at least one of the point " u"features impacting scenic quality."), label=u'Overlap Analysis Features (Vector)', validator=self.validator) self.general_tab.add_input(self.overlap_uri) self.valuation_tab = inputs.Container( interactive=True, label=u'Valuation') self.add_input(self.valuation_tab) self.valuation_function = inputs.Dropdown( args_key=u'valuation_function', helptext=( u"This field indicates the functional form f(x) the " u"model will use to value the visual impact for each " u"viewpoint. For distances less than 1 km (x<1), the " u"model uses a linear form g(x) where the line passes " u"through f(1) (i.e. g(1) == f(1)) and extends to zero " u"with the same slope as f(1) (i.e. g'(x) == f'(1))."), label=u'Valuation Function', options=[u'polynomial: a + bx + cx^2 + dx^3', u'logarithmic: a + b ln(x)']) self.valuation_tab.add_input(self.valuation_function) self.a_coefficient = inputs.Text( args_key=u'a_coefficient', helptext=( u"First coefficient used either by the polynomial or " u"by the logarithmic valuation function."), label=u"'a' Coefficient (polynomial/logarithmic)", validator=self.validator) self.valuation_tab.add_input(self.a_coefficient) self.b_coefficient = inputs.Text( args_key=u'b_coefficient', helptext=( u"Second coefficient used either by the polynomial or " u"by the logarithmic valuation function."), label=u"'b' Coefficient (polynomial/logarithmic)", validator=self.validator) self.valuation_tab.add_input(self.b_coefficient) self.c_coefficient = inputs.Text( args_key=u'c_coefficient', helptext=u"Third coefficient for the polynomial's quadratic term.", label=u"'c' Coefficient (polynomial only)", validator=self.validator) self.valuation_tab.add_input(self.c_coefficient) self.d_coefficient = inputs.Text( args_key=u'd_coefficient', helptext=u"Fourth coefficient for the polynomial's cubic exponent.", label=u"'d' Coefficient (polynomial only)", validator=self.validator) self.valuation_tab.add_input(self.d_coefficient) self.max_valuation_radius = inputs.Text( args_key=u'max_valuation_radius', helptext=( u"Radius beyond which the valuation is set to zero. " u"The valuation function 'f' cannot be negative at the " u"radius 'r' (f(r)>=0)."), label=u'Maximum Valuation Radius (meters)', validator=self.validator) self.valuation_tab.add_input(self.max_valuation_radius)
def __init__(self): model.InVESTModel.__init__( self, label=MODEL_METADATA['recreation'].model_title, target=recmodel_client.execute, validator=recmodel_client.validate, localdoc=MODEL_METADATA['recreation'].userguide) self.internet_warning = inputs.Label( text=("Note, this computer must have an Internet connection " "in order to run this model.")) self.aoi_path = inputs.File( args_key='aoi_path', helptext=("An OGR-supported vector file representing the area " "of interest where the model will run the analysis."), label='Area of Interest (Vector)', validator=self.validator) self.add_input(self.aoi_path) self.start_year = inputs.Text( args_key='start_year', helptext='Year to start PUD calculations, date starts on Jan 1st.', label='Start Year (inclusive, must be >= 2005)', validator=self.validator) self.add_input(self.start_year) self.end_year = inputs.Text( args_key='end_year', helptext=('Year to end PUD calculations, date ends and includes ' 'Dec 31st.'), label='End Year (inclusive, must be <= 2017)', validator=self.validator) self.add_input(self.end_year) self.regression_container = inputs.Container( args_key='compute_regression', expandable=True, expanded=True, label='Compute Regression') self.add_input(self.regression_container) self.predictor_table_path = inputs.File( args_key='predictor_table_path', helptext=("A table that maps predictor IDs to files and their " "types with required headers of 'id', 'path', and " "'type'. The file paths can be absolute, or relative " "to the table."), label='Predictor Table', validator=self.validator) self.regression_container.add_input(self.predictor_table_path) self.scenario_predictor_table_path = inputs.File( args_key='scenario_predictor_table_path', helptext=("A table that maps predictor IDs to files and their " "types with required headers of 'id', 'path', and " "'type'. The file paths can be absolute, or relative " "to the table."), label='Scenario Predictor Table (optional)', validator=self.validator) self.regression_container.add_input(self.scenario_predictor_table_path) self.grid_container = inputs.Container(args_key='grid_aoi', expandable=True, expanded=True, label='Grid the AOI') self.add_input(self.grid_container) self.grid_type = inputs.Dropdown(args_key='grid_type', label='Grid Type', options=['square', 'hexagon']) self.grid_container.add_input(self.grid_type) self.cell_size = inputs.Text( args_key='cell_size', helptext=("The size of the grid units measured in the " "projection units of the AOI. For example, UTM " "projections use meters."), label='Cell Size', validator=self.validator) self.grid_container.add_input(self.cell_size)
def __init__(self): model.InVESTModel.__init__( self, label=MODEL_METADATA['fisheries_hst'].model_title, target=fisheries_hst.execute, validator=fisheries_hst.validate, localdoc=MODEL_METADATA['fisheries_hst'].userguide) self.alpha_only = inputs.Label( text=("This tool is in an ALPHA testing stage and should " "not be used for decision making.")) self.pop_cont = inputs.Container(args_key='pop_cont', expanded=True, label='Population Parameters') self.add_input(self.pop_cont) self.population_csv_path = inputs.File( args_key='population_csv_path', helptext=("A CSV file containing all necessary attributes for " "population classes based on age/stage, sex, and area " "- excluding possible migration " "information.<br><br>See the 'Running the Model >> " "Core Model >> Population Parameters' section in the " "model's documentation for help on how to format this " "file."), label='Population Parameters File (CSV)', validator=self.validator) self.pop_cont.add_input(self.population_csv_path) self.sexsp = inputs.Dropdown( args_key='sexsp', helptext=("Specifies whether or not the population classes " "provided in the Populaton Parameters CSV file are " "distinguished by sex."), label='Population Classes are Sex-Specific', options=['No', 'Yes']) self.pop_cont.add_input(self.sexsp) self.hab_cont = inputs.Container(args_key='hab_cont', expanded=True, label='Habitat Parameters') self.add_input(self.hab_cont) self.habitat_csv_dep_path = inputs.File( args_key='habitat_dep_csv_path', helptext=("A CSV file containing the habitat dependencies (0-1) " "for each life stage or age and for each habitat type " "included in the Habitat Change CSV File.<br><br>See " "the 'Running the Model >> Habitat Scenario Tool >> " "Habitat Parameters' section in the model's " "documentation for help on how to format this file."), label='Habitat Dependency Parameters File (CSV)', validator=self.validator) self.hab_cont.add_input(self.habitat_csv_dep_path) self.habitat_chg_csv_path = inputs.File( args_key='habitat_chg_csv_path', helptext=("A CSV file containing the percent changes in habitat " "area by subregion (if applicable). The habitats " "included should be those which the population depends " "on at any life stage.<br><br>See the 'Running the " "Model >> Habitat Scenario Tool >> Habitat Parameters' " "section in the model's documentation for help on how " "to format this file."), label='Habitat Area Change File (CSV)', validator=self.validator) self.hab_cont.add_input(self.habitat_chg_csv_path) self.gamma = inputs.Text( args_key='gamma', helptext=("Gamma describes the relationship between a change in " "habitat area and a change in survival of life stages " "dependent on that habitat. Specify a value between 0 " "and 1.<br><br>See the documentation for advice on " "selecting a gamma value."), label='Gamma', validator=self.validator) self.hab_cont.add_input(self.gamma)
def __init__(self): model.InVESTModel.__init__( self, label=MODEL_METADATA['fisheries'].model_title, target=fisheries.execute, validator=fisheries.validate, localdoc=MODEL_METADATA['fisheries'].userguide) self.alpha_only = inputs.Label( text=("This tool is in an ALPHA testing stage and should " "not be used for decision making.")) self.aoi_vector_path = inputs.File( args_key='aoi_vector_path', helptext=("An OGR-supported vector file used to display outputs " "within the region(s) of interest.<br><br>The layer " "should contain one feature for every region of " "interest, each feature of which should have a ‘NAME’ " "attribute. The 'NAME' attribute can be numeric or " "alphabetic, but must be unique within the given file."), label='Area of Interest (Vector) (Optional)', validator=self.validator) self.add_input(self.aoi_vector_path) self.total_timesteps = inputs.Text( args_key='total_timesteps', helptext=("The number of time steps the simulation shall " "execute before completion.<br><br>Must be a positive " "integer."), label='Number of Time Steps for Model Run', validator=self.validator) self.add_input(self.total_timesteps) self.popu_cont = inputs.Container(label='Population Parameters') self.add_input(self.popu_cont) self.population_type = inputs.Dropdown( args_key='population_type', helptext=("Specifies whether the lifecycle classes provided in " "the Population Parameters CSV file represent ages " "(uniform duration) or stages.<br><br>Age-based models " "(e.g. Lobster, Dungeness Crab) are separated by " "uniform, fixed-length time steps (usually " "representing a year).<br><br>Stage-based models (e.g. " "White Shrimp) allow lifecycle-classes to have " "nonuniform durations based on the assumed resolution " "of the provided time step.<br><br>If the stage-based " "model is selected, the Population Parameters CSV file " "must include a ‘Duration’ vector alongside the " "survival matrix that contains the number of time " "steps that each stage lasts."), label='Population Model Type', options=['Age-Based', 'Stage-Based']) self.popu_cont.add_input(self.population_type) self.sexsp = inputs.Dropdown( args_key='sexsp', helptext=("Specifies whether or not the lifecycle classes " "provided in the Populaton Parameters CSV file are " "distinguished by sex."), label='Population Classes are Sex-Specific', options=['No', 'Yes']) self.popu_cont.add_input(self.sexsp) self.harvest_units = inputs.Dropdown( args_key='harvest_units', helptext=("Specifies whether the harvest output values are " "calculated in terms of number of individuals or in " "terms of biomass (weight).<br><br>If ‘Weight’ is " "selected, the Population Parameters CSV file must " "include a 'Weight' vector alongside the survival " "matrix that contains the weight of each lifecycle " "class and sex if model is sex-specific."), label='Harvest by Individuals or Weight', options=['Individuals', 'Weight']) self.popu_cont.add_input(self.harvest_units) self.do_batch = inputs.Checkbox( args_key='do_batch', helptext=("Specifies whether program will perform a single " "model run or a batch (set) of model runs.<br><br>For " "single model runs, users submit a filepath pointing " "to a single Population Parameters CSV file. For " "batch model runs, users submit a directory path " "pointing to a set of Population Parameters CSV files."), label='Batch Processing') self.popu_cont.add_input(self.do_batch) self.population_csv_path = inputs.File( args_key='population_csv_path', helptext=("The provided CSV file should contain all necessary " "attributes for the sub-populations based on lifecycle " "class, sex, and area - excluding possible migration " "information.<br><br>Please consult the documentation " "to learn more about what content should be provided " "and how the CSV file should be structured."), label='Population Parameters File (CSV)', validator=self.validator) self.popu_cont.add_input(self.population_csv_path) self.population_csv_dir = inputs.Folder( args_key='population_csv_dir', helptext=("The provided CSV folder should contain a set of " "Population Parameters CSV files with all necessary " "attributes for sub-populations based on lifecycle " "class, sex, and area - excluding possible migration " "information.<br><br>The name of each file will serve " "as the prefix of the outputs created by the model " "run.<br><br>Please consult the documentation to learn " "more about what content should be provided and how " "the CSV file should be structured."), interactive=False, label='Population Parameters CSV Folder', validator=self.validator) self.popu_cont.add_input(self.population_csv_dir) self.recr_cont = inputs.Container(label='Recruitment Parameters') self.add_input(self.recr_cont) self.total_init_recruits = inputs.Text( args_key='total_init_recruits', helptext=("The initial number of recruits in the population " "model at time equal to zero.<br><br>If the model " "contains multiple regions of interest or is " "distinguished by sex, this value will be evenly " "divided and distributed into each sub-population."), label='Total Initial Recruits', validator=self.validator) self.recr_cont.add_input(self.total_init_recruits) self.recruitment_type = inputs.Dropdown( args_key='recruitment_type', helptext=("The selected equation is used to calculate " "recruitment into the subregions at the beginning of " "each time step. Corresponding parameters must be " "specified with each function:<br><br>The Beverton- " "Holt and Ricker functions both require arguments for " "the ‘Alpha’ and ‘Beta’ parameters.<br><br>The " "Fecundity function requires a 'Fecundity' vector " "alongside the survival matrix in the Population " "Parameters CSV file indicating the per-capita " "offspring for each lifecycle class.<br><br>The Fixed " "function requires an argument for the ‘Total Recruits " "per Time Step’ parameter that represents a single " "total recruitment value to be distributed into the " "population model at the beginning of each time step."), label='Recruitment Function Type', options=['Beverton-Holt', 'Ricker', 'Fecundity', 'Fixed']) self.recr_cont.add_input(self.recruitment_type) self.spawn_units = inputs.Dropdown( args_key='spawn_units', helptext=("Specifies whether the spawner abundance used in the " "recruitment function should be calculated in terms of " "number of individuals or in terms of biomass " "(weight).<br><br>If 'Weight' is selected, the user " "must provide a 'Weight' vector alongside the survival " "matrix in the Population Parameters CSV file. The " "'Alpha' and 'Beta' parameters provided by the user " "should correspond to the selected choice.<br><br>Used " "only for the Beverton-Holt and Ricker recruitment " "functions."), label='Spawners by Individuals or Weight (Beverton-Holt / Ricker)', options=['Individuals', 'Weight']) self.recr_cont.add_input(self.spawn_units) self.alpha = inputs.Text( args_key='alpha', helptext=("Specifies the shape of the stock-recruit curve. " "Used only for the Beverton-Holt and Ricker " "recruitment functions.<br><br>Used only for the " "Beverton-Holt and Ricker recruitment functions."), label='Alpha (Beverton-Holt / Ricker)', validator=self.validator) self.recr_cont.add_input(self.alpha) self.beta = inputs.Text( args_key='beta', helptext=("Specifies the shape of the stock-recruit " "curve.<br><br>Used only for the Beverton-Holt and " "Ricker recruitment functions."), label='Beta (Beverton-Holt / Ricker)', validator=self.validator) self.recr_cont.add_input(self.beta) self.total_recur_recruits = inputs.Text( args_key='total_recur_recruits', helptext=("Specifies the total number of recruits that come " "into the population at each time step (a fixed " "number).<br><br>Used only for the Fixed recruitment " "function."), label='Total Recruits per Time Step (Fixed)', validator=self.validator) self.recr_cont.add_input(self.total_recur_recruits) self.migr_cont = inputs.Container(args_key='migr_cont', expandable=True, expanded=False, label='Migration Parameters') self.add_input(self.migr_cont) self.migration_dir = inputs.Folder( args_key='migration_dir', helptext=("The selected folder contain CSV migration matrices " "to be used in the simulation. Each CSV file contains " "a single migration matrix corresponding to an " "lifecycle class that migrates. The folder should " "contain one CSV file for each lifecycle class that " "migrates.<br><br>The files may be named anything, but " "must end with an underscore followed by the name of " "the age or stage. The name of the age or stage must " "correspond to an age or stage within the Population " "Parameters CSV file. For example, a migration file " "might be named 'migration_adult.csv'.<br><br>Each " "matrix cell should contain a decimal fraction " "indicating the percetage of the population that will " "move from one area to another. Each column should " "sum to one."), label='Migration Matrix CSV Folder (Optional)', validator=self.validator) self.migr_cont.add_input(self.migration_dir) self.val_cont = inputs.Container(args_key='val_cont', expandable=True, expanded=False, label='Valuation Parameters') self.add_input(self.val_cont) self.frac_post_process = inputs.Text( args_key='frac_post_process', helptext=("Decimal fraction indicating the percentage of " "harvested catch remaining after post-harvest " "processing is complete."), label='Fraction of Harvest Kept After Processing', validator=self.validator) self.val_cont.add_input(self.frac_post_process) self.unit_price = inputs.Text( args_key='unit_price', helptext=("Specifies the price per harvest unit.<br><br>If " "‘Harvest by Individuals or Weight’ was set to " "‘Individuals’, this should be the price per " "individual. If set to ‘Weight’, this should be the " "price per unit weight."), label='Unit Price', validator=self.validator) self.val_cont.add_input(self.unit_price) # Set interactivity, requirement as input sufficiency changes self.do_batch.sufficiency_changed.connect(self._toggle_batch_runs) # Enable/disable parameters when the recruitment function changes. self.recruitment_type.value_changed.connect( self._control_recruitment_parameters)
def __init__(self): model.InVESTModel.__init__( self, label='Habitat Risk Assessment Preprocessor', target=hra_preprocessor.execute, validator=hra_preprocessor.validate, localdoc='../documentation/habitat_risk_assessment.html') self.habs_dir = inputs.File( args_key='habitats_dir', helptext=( "Checking this box indicates that habitats should be " "used as a base for overlap with provided stressors. " "If checked, the path to the habitat layers folder " "must be provided."), hideable=True, label='Calculate Risk to Habitats?', validator=self.validator) self.add_input(self.habs_dir) self.species_dir = inputs.File( args_key='species_dir', helptext=( "Checking this box indicates that species should be " "used as a base for overlap with provided stressors. " "If checked, the path to the species layers folder " "must be provided."), hideable=True, label='Calculate Risk to Species?', validator=self.validator) self.add_input(self.species_dir) self.stressor_dir = inputs.Folder( args_key='stressors_dir', helptext='This is the path to the stressors layers folder.', label='Stressors Layers Folder', validator=self.validator) self.add_input(self.stressor_dir) self.cur_lulc_box = inputs.Container( expandable=False, label='Criteria') self.add_input(self.cur_lulc_box) self.help_label = inputs.Label( text=( "(Choose at least 1 criteria for each category below, " "and at least 4 total.)")) self.exp_crit = inputs.Multi( args_key='exposure_crits', callable_=functools.partial(inputs.Text, label="Input Criteria"), label='Exposure', link_text='Add Another') self.cur_lulc_box.add_input(self.exp_crit) self.sens_crit = inputs.Multi( args_key='sensitivity_crits', callable_=functools.partial(inputs.Text, label="Input Criteria"), label='Consequence: Sensitivity', link_text='Add Another') self.cur_lulc_box.add_input(self.sens_crit) self.res_crit = inputs.Multi( args_key='resilience_crits', callable_=functools.partial(inputs.Text, label="Input Criteria"), label='Consequence: Resilience', link_text='Add Another') self.cur_lulc_box.add_input(self.res_crit) self.crit_dir = inputs.File( args_key='criteria_dir', helptext=( "Checking this box indicates that model should use " "criteria from provided shapefiles. Each shapefile in " "the folder directories will need to contain a " "'Rating' attribute to be used for calculations in the " "HRA model. Refer to the HRA User's Guide for " "information about the MANDATORY layout of the " "shapefile directories."), hideable=True, label='Use Spatially Explicit Risk Score in Shapefiles', validator=self.validator) self.add_input(self.crit_dir)