pywatershed.PRMSSolarGeometry#

class pywatershed.PRMSSolarGeometry(control, discretization, parameters, verbose=False, from_prms_file=None, from_nc_files_dir=None)[source]#

PRMS solar geometry.

Implementation based on PRMS 5.2.1 with theoretical documentation given in the PRMS-IV documentation:

Markstrom, S. L., Regan, R. S., Hay, L. E., Viger, R. J., Webb, R. M., Payn, R. A., & LaFontaine, J. H. (2015). PRMS-IV, the precipitation-runoff modeling system, version 4. US Geological Survey Techniques and Methods, 6, B7.

Implements Swift’s daily potential solar radiation and number of hours of duration on a sloping surface in [cal/cm2/day]. Swift, 1976, equation 6.

Primary reference: Appendix E of Dingman, S. L., 1994, Physical Hydrology. Englewood Cliffs, NJ: Prentice Hall, 575 p.

Parameters:
  • control – a Control object

  • discretization – a discretization of class Parameters

  • parameters – a parameter object of class Parameters

  • verbose – Print extra information or not?

  • from_prms_file – Load from a PRMS output file?

  • from_nc_files_dir – [str, pl.Path] = None,

__init__(control, discretization, parameters, verbose=False, from_prms_file=None, from_nc_files_dir=None)[source]#

Methods

__init__(control, discretization, parameters)

advance()

Advance the Process in time.

calculate(time_length, **kwargs)

Calculate Process terms for a time step

compute_soltab(slopes, aspects, lats, ...)

Calculate the solar table :param cossl: cos(atan(hru_slope)) [nhru] ? :param slope: slope [nhru] :param aspect: aspect [nhru] :param latitude: latitude [nhru]

compute_t(lats, solar_declination)

The "sunrise" equation

description()

A dictionary description of this Process.

finalize()

Finalizes the Process, including output methods.

func3(v, w, x, y)

Potential solar radiation on the surface cal/cm2/day

get_dimensions()

Get a tuple of dimension names for this Process.

get_init_values()

Get a dictionary of initialization values for each public variable.

get_inputs()

Get a tuple of input variable names for this Process.

get_parameters()

Get a tuple of parameter names for this Process.

get_restart_variables()

Get a list of restart varible names.

get_variables()

Get a tuple of (public) variable names for this Process.

initialize_netcdf([output_dir, ...])

Initialize NetCDF output.

output()

Output data to previously initialized output types.

output_to_csv(pth)

Save each output variable to separate csv file in specified path

set_input_to_adapter(input_variable_name, ...)

Attributes

dimensions

A tuple of parameter names.

init_values

A dictionary of initial values for each public variable.

inputs

A tuple of input variable names.

parameters

A tuple of parameter names.

restart_variables

A tuple of restart variable names.

variables

A tuple of public variable names.

advance()#

Advance the Process in time.

Returns:

None

calculate(time_length, **kwargs)#

Calculate Process terms for a time step

Parameters:

simulation_time – current simulation time

Return type:

None

Returns:

None

static compute_soltab(slopes, aspects, lats, compute_t, func3)[source]#

Calculate the solar table :param cossl: cos(atan(hru_slope)) [nhru] ? :param slope: slope [nhru] :param aspect: aspect [nhru] :param latitude: latitude [nhru]

Return type:

Tuple[ndarray, ndarray]

Returns: (solt, sunh)
solt: Swift’s potential solar radiation on a sloping surface in

[cal/cm2/day]. Swift, 1976, equation 6. Dimensions: [ndoy, nhru]

sunh: The number of hours of direct sunlight

Dimensions: [ndoy, nhru]

static compute_t(lats, solar_declination)[source]#

The “sunrise” equation

Parameters:
  • hrus (lats - latitudes of the) –

  • solar_declination (ndarray) – the declination of the sun on all julian days

Return type:

ndarray

Returns:

The angle hour from the local meridian (local solar noon) to the sunrise (negative) or sunset (positive). The Earth rotates at the angular speed of 15 degrees/hour (2 pi / 24 hour in radians) and, therefore, result*(24/(2pi) radians gives the time of sunrise as the number of hours before the local noon, or the time of sunset as the number of hours after the local noon. Here the term local noon indicates the local time when the sun is exactly to the south or north or exactly overhead.

See reference: nhm-usgs/prms

classmethod description()#

A dictionary description of this Process.

Return type:

dict

Returns:

All metadata for all variables in inputs, variables, and parameters.

property dimensions: tuple#

A tuple of parameter names.

finalize()#

Finalizes the Process, including output methods. :rtype: None :returns: None

static func3(v, w, x, y)[source]#

Potential solar radiation on the surface cal/cm2/day

Radian angle version of FUNC3 (eqn 6) from Swift, 1976 or Lee, 1963 equation 5. (Names in parens below from Swift?)

Parameters:
  • v (ndarray) – (L2) latitude angle hour offset between actual and equivalent slope [nhru]

  • w (ndarray) – (L1) latitude of the equivalent slope [nhru]

  • x (ndarray) – (T3) hour angle of sunset on equivalent slope [ndoy, nhru]

  • y (ndarray) – (T2) hour angle of sunrise on equivalent slope [ndoy, nhru]

Return type:

ndarray

Returns:

(R4) is potential solar radiation on the surface cal/cm2/day [ndoy, nhru]

Constants

r1: solar constant for 60 minutes [ndoy] solar_declination: declination of sun [ndoy]

See also: nhm-usgs/prms

static get_dimensions()[source]#

Get a tuple of dimension names for this Process.

Return type:

tuple

static get_init_values()[source]#

Get a dictionary of initialization values for each public variable.

Return type:

dict

static get_inputs()[source]#

Get a tuple of input variable names for this Process.

Return type:

tuple

static get_parameters()[source]#

Get a tuple of parameter names for this Process.

Return type:

tuple

static get_restart_variables()#

Get a list of restart varible names.

Return type:

list

static get_variables()[source]#

Get a tuple of (public) variable names for this Process.

property init_values: dict#

A dictionary of initial values for each public variable.

initialize_netcdf(output_dir=None, separate_files=None, output_vars=None, **kwargs)[source]#

Initialize NetCDF output.

Parameters:
  • output_dir – base directory path or NetCDF file path if separate_files is True

  • separate_files – boolean indicating if storage component output variables should be written to a separate file for each variable

  • output_vars – list of variable names to outuput.

Returns:

None

property inputs: tuple#

A tuple of input variable names.

output()[source]#

Output data to previously initialized output types. :returns: None

output_to_csv(pth)#

Save each output variable to separate csv file in specified path

property parameters: tuple#

A tuple of parameter names.

property restart_variables: tuple#

A tuple of restart variable names.

set_input_to_adapter(input_variable_name, adapter)#
property variables: tuple#

A tuple of public variable names.