8.3.7. Data Accessor
8.3.7.1. Introduction
The DataAccessor class is a helper class for extracting numpy arrays from a given
ParFlow run.
8.3.7.2. Usage of DataAccessor
First, we’ll show some examples of using the DataAccessor class within a ParFlow Python script:
from parflow import Run
# Create a Run object from a .pfidb file
run = Run.from_definition('/path/to/pfidb/file')
# Get the DataAccessor object corresponding to the Run object
data = run.data_accessor
# Iterate through the timesteps of the DataAccessor object
# i goes from 0 to n_timesteps - 1
for i in data.times:
#----------------------------- Evapotranspiration -------------------------------
# nz-by-ny-by-nx array of ET values (bottom to top layer)
print(data.et)
#------------------------------- Overland Flow ----------------------------------
# ny-by-nx array of overland flow values - 'OverlandKinematic' flow method
print(data.overland_flow_grid())
# ny-by-nx array of overland flow values - 'OverlandFlow' flow method
print(data.overland_flow_grid(flow_method='OverlandFlow'))
# Total outflow for the domain (scalar value) - 'OverlandKinematic' flow method
print(data.overland_flow())
# Total outflow for the domain (scalar value) - 'OverlandFlow' flow method
print(data.overland_flow(flow_method='OverlandFlow'))
#-------------------------- Subsurface/Surface Storage --------------------------
# nz-by-ny-by-nx array of subsurface storage values (bottom to top layer)
print(data.subsurface_storage)
# ny-by-nx array of surface storage values
print(data.surface_storage)
#----------------------------- Water Table Depth --------------------------------
# ny-by-nx array of water table depth values
print(data.wtd)
data.time += 1
8.3.7.3. Full API
run.data_accessorAccesses the
DataAccessorobject on the currentRunobjectrun.- return
An instance of the
DataAccessorclass.
data.timeGet current timestep set on the current
DataAccessorobjectdata. This timestep will be used to determine the file index for accessing timeseries data.- return
An integer value representing the current timestep.
data.times- return
An array of timesteps on the current
DataAccessorobjectdata, from 0 to n_timesteps - 1.
data.forcing_timeGet current forcing timestep set on the current
DataAccessorobjectdata. This timestep will be used to determine the file index for accessing forcing timeseries data.- return
An integer value representing the current forcing timestep.
data.shape- return
Tuple containing
(ComputationalGrid.NZ, ComputationalGrid.NY, ComputationalGrid.NX)set on the currentDataAccessorobjectdata.
data.dx- return
Value of
ComputationalGrid.DXon the currentDataAccessorobjectdata.
data.dy- return
Value of
ComputationalGrid.DYon the currentDataAccessorobjectdata.
data.dz- return
Array of size
ComputationalGrid.NZcontaining eitherdz_scalevalues or the value ofComputationalGrid.DZset on the currentDataAccessorobjectdata.
data.mannings- return
An
ndarraycontaining mannings roughness coefficient data for the currentDataAccessorobjectdata.
data.mask- return
An
ndarraycontaining the mask of your domain for the currentDataAccessorobjectdata.
data.slope_x- return
An
ndarraycontaining thextopographic slope values for the currentDataAccessorobjectdata.
data.slope_y- return
An
ndarraycontaining theytopographic slope values for the currentDataAccessorobjectdata.
data.elevation- return
An
ndarraycontaining the elevation topographic slope values for the currentDataAccessorobjectdata.
data.computed_porosity- return
An
ndarraycontaining computed porosity values on the currentDataAccessorobjectdata.
data.computed_permeability_x- return
An
ndarraycontaining computed permeabilityxvalues on the currentDataAccessorobjectdata.
data.computed_permeability_y- return
An
ndarraycontaining computed permeabilityyvalues on the currentDataAccessorobjectdata.
data.computed_permeability_z- return
An
ndarraycontaining computed permeabilityzvalues on the currentDataAccessorobjectdata.
data.pressure_initial_condition- return
An
ndarraycontaining initial condition pressure values on the currentDataAccessorobjectdata.
data.pressure_boundary_conditions- return
A dictionary containing
key=valuepairs of the form{patch_name}__{cycle_name} = valuefor pressure boundary conditions on the currentDataAccessorobjectdata.
data.pressure- return
An
ndarraycontaining pressure values for the current timestep set on theDataAccessorobjectdata.
data.saturation- return
An
ndarraycontaining saturation values for the current timestep set on theDataAccessorobjectdata.
data.specific_storage- return
An
ndarraycontaining specific storage values for the currentDataAccessorobjectdata.
data.et- return
An
nzbynybynxndarrayof evapotranspiration values (units L^3/T), spanning all layers (bottom to top) for the currentDataAccessorobjectdata.
data.overland_flow(flow_method='OverlandKinematic', epsilon=1e-5)- param
flow_method Either
'OverlandFlow'or'OverlandKinematic'.'OverlandKinematic'by default.- param
epsilon Minimum slope magnitude for solver. Only applicable if
flow_method='OverlandKinematic'. This is set using theSolver.OverlandKinematic.Epsilonkey in Parflow.- return
An
nybynxndarrayof overland flow values for the currentDataAccessorobjectdata.
- param
data.overland_flow_grid(flow_method='OverlandKinematic', epsilon=1e-5)- param
flow_method Either
'OverlandFlow'or'OverlandKinematic'.'OverlandKinematic'by default.- param
epsilon Minimum slope magnitude for solver. Only applicable if
kinematic=True. This is set using theSolver.OverlandKinematic.Epsilonkey in Parflow.- return
An
nybynxndarrayof overland flow values for the currentDataAccessorobjectdata.
- param
data.subsurface_storage- return
An
nzbynybynxndarrayof subsurface storage values, spanning all layers (bottom to top), for the currentDataAccessorobjectdata.
data.surface_storage- return
An
nybynxndarrayof surface storage values for the currentDataAccessorobjectdata.
data.wtd- return
An
nybynxndarrayof water table depth values (measured from the top) for the currentDataAccessorobjectdata.
data.clm_output(field, layer=-1)- param field
CLM field, one of:
'eflx_lh_tot', 'eflx_lwrad_out', 'eflx_sh_tot', 'eflx_soil_grnd', 'qflx_evap_tot', 'qflx_evap_grnd', 'qflx_evap_soi', 'qflx_evap_veg', 'qflx_tran_veg', 'qflx_infl', 'swe_out', 't_grnd', 'qflx_qirr', 't_soil'- param layer
Layer of data
- return
An
ndarrayof CLM output for the givenfieldandlayeron the currentDataAccessorobjectdata.
data.clm_output_variables- return
Tuple containing names of all CLM output variables:
('eflx_lh_tot', 'eflx_lwrad_out', 'eflx_sh_tot', 'eflx_soil_grnd', 'qflx_evap_tot', 'qflx_evap_grnd', 'qflx_evap_soi', 'qflx_evap_veg', 'qflx_tran_veg', 'qflx_infl', 'swe_out', 't_grnd', 'qflx_qirr', 't_soil')
data.clm_output_diagnostics- return
String filepath to CLM output diagnostics file for the current
DataAccessorobjectdata.
data.clm_output_eflx_lh_tot- return
An
ndarraycontaining CLMeflx_lh_totdata for the currentDataAccessorobjectdata.
data.clm_output_eflx_lwrad_out- return
An
ndarraycontaining CLMeflx_lwrad_outdata for the currentDataAccessorobjectdata.
data.clm_output_eflx_sh_tot- return
An
ndarraycontaining CLMeflx_sh_totdata for the currentDataAccessorobjectdata.
data.clm_output_eflx_soil_grnd- return
An
ndarraycontaining CLMeflx_soil_grnddata for the currentDataAccessorobjectdata.
data.clm_output_qflx_evap_grnd- return
An
ndarraycontaining CLMqflx_evap_grnddata for the currentDataAccessorobjectdata.
data.clm_output_qflx_evap_soi- return
An
ndarraycontaining CLMqflx_evap_soidata for the currentDataAccessorobjectdata.
data.lm_output_qflx_evap_tot- return
An
ndarraycontaining CLMqflx_evap_totdata for the currentDataAccessorobjectdata.
data.clm_output_qflx_evap_veg- return
An
ndarraycontaining CLMqflx_evap_vegdata for the currentDataAccessorobjectdata.
data.clm_output_qflx_infl- return
An
ndarraycontaining CLMqflx_infldata for the currentDataAccessorobjectdata.
data.clm_output_qflx_top_soil- return
An
ndarraycontaining CLMqflx_top_soildata for the currentDataAccessorobjectdata.
data.clm_output_qflx_tran_veg- return
An
ndarraycontaining CLMqflx_tran_vegdata for the currentDataAccessorobjectdata.
data.clm_output_swe_out- return
An
ndarraycontaining CLMswe_outdata for the currentDataAccessorobjectdata.
data.clm_output_t_grnd- return
An
ndarraycontaining CLMt_grnddata for the currentDataAccessorobjectdata.
data.clm_forcing(name)- param
name Forcing type you’re interested in
- return
An
ndarraycontaining CLM forcing data for the givennameand forcing timestep set on the currentDataAccessorobjectdata.
- param
data.clm_forcing_dswr- return
An
ndarraycontaining CLM forcing data for Downward Visible or Short-Wave radiation [W/m2] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_dlwr- return
An
ndarraycontaining CLM forcing data for Downward Infa-Red or Long-Wave radiation [W/m2] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_apcp- return
An
ndarraycontaining CLM forcing data for Precipitation rate [mm/s] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_temp- return
An
ndarraycontaining CLM forcing data for Air temperature [K] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_ugrd- return
An
ndarraycontaining CLM forcing data for West-to-East or U-component of wind [m/s] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_vgrd- return
An
ndarraycontaining CLM forcing data for South-to-North or V-component of wind [m/s] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_press- return
An
ndarraycontaining CLM forcing data for Atmospheric Pressure [pa] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_forcing_spfh- return
An
ndarraycontaining CLM forcing data for Water-vapor specific humidity [kg/kg] for the forcing timestep set on the currentDataAccessorobjectdata.
data.clm_map_land_fraction(name)- param name
Type of land frac data you’re interested in
- return
Data corresponding to
Solver.CLM.Vegetation.Map.LandFrac[name]key set on the ParFlow run for the currentDataAccessorobjectdata.
data.clm_map_latitude- return
Data corresponding to
Solver.CLM.Vegetation.Map.Latitudekey set on the ParFlow run for the currentDataAccessorobjectdata.
data.clm_map_longitude- return
Data corresponding to
Solver.CLM.Vegetation.Map.Longitudekey set on the ParFlow run for the currentDataAccessorobjectdata.
data.clm_map_sand- return
Data corresponding to
Solver.CLM.Vegetation.Map.Sandkey set on the ParFlow run for the currentDataAccessorobjectdata.
data.clm_map_clay- return
Data corresponding to
Solver.CLM.Vegetation.Map.Claykey set on the ParFlow run for the currentDataAccessorobjectdata.
data.clm_map_color- return
Data corresponding to
Solver.CLM.Vegetation.Map.Colorkey set on the ParFlow run for the currentDataAccessorobjectdata.