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

  1. run.data_accessor

    Accesses the DataAccessor object on the current Run object run.

    return

    An instance of the DataAccessor class.

  2. data.time

    Get current timestep set on the current DataAccessor object data. This timestep will be used to determine the file index for accessing timeseries data.

    return

    An integer value representing the current timestep.

  3. data.times
    return

    An array of timesteps on the current DataAccessor object data, from 0 to n_timesteps - 1.

  4. data.forcing_time

    Get current forcing timestep set on the current DataAccessor object data. This timestep will be used to determine the file index for accessing forcing timeseries data.

    return

    An integer value representing the current forcing timestep.

  5. data.shape
    return

    Tuple containing (ComputationalGrid.NZ, ComputationalGrid.NY, ComputationalGrid.NX) set on the current DataAccessor object data.

  6. data.dx
    return

    Value of ComputationalGrid.DX on the current DataAccessor object data.

  7. data.dy
    return

    Value of ComputationalGrid.DY on the current DataAccessor object data.

  8. data.dz
    return

    Array of size ComputationalGrid.NZ containing either dz_scale values or the value of ComputationalGrid.DZ set on the current DataAccessor object data.

  9. data.mannings
    return

    An ndarray containing mannings roughness coefficient data for the current DataAccessor object data.

  10. data.mask
    return

    An ndarray containing the mask of your domain for the current DataAccessor object data.

  11. data.slope_x
    return

    An ndarray containing the x topographic slope values for the current DataAccessor object data.

  12. data.slope_y
    return

    An ndarray containing the y topographic slope values for the current DataAccessor object data.

  13. data.elevation
    return

    An ndarray containing the elevation topographic slope values for the current DataAccessor object data.

  14. data.computed_porosity
    return

    An ndarray containing computed porosity values on the current DataAccessor object data.

  15. data.computed_permeability_x
    return

    An ndarray containing computed permeability x values on the current DataAccessor object data.

  16. data.computed_permeability_y
    return

    An ndarray containing computed permeability y values on the current DataAccessor object data.

  17. data.computed_permeability_z
    return

    An ndarray containing computed permeability z values on the current DataAccessor object data.

  18. data.pressure_initial_condition
    return

    An ndarray containing initial condition pressure values on the current DataAccessor object data.

  19. data.pressure_boundary_conditions
    return

    A dictionary containing key=value pairs of the form {patch_name}__{cycle_name} = value for pressure boundary conditions on the current DataAccessor object data.

  20. data.pressure
    return

    An ndarray containing pressure values for the current timestep set on the DataAccessor object data.

  21. data.saturation
    return

    An ndarray containing saturation values for the current timestep set on the DataAccessor object data.

  22. data.specific_storage
    return

    An ndarray containing specific storage values for the current DataAccessor object data.

  23. data.et
    return

    An nz by ny by nx ndarray of evapotranspiration values (units L^3/T), spanning all layers (bottom to top) for the current DataAccessor object data.

  24. 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 the Solver.OverlandKinematic.Epsilon key in Parflow.

    return

    An ny by nx ndarray of overland flow values for the current DataAccessor object data.

  25. 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 the Solver.OverlandKinematic.Epsilon key in Parflow.

    return

    An ny by nx ndarray of overland flow values for the current DataAccessor object data.

  26. data.subsurface_storage
    return

    An nz by ny by nx ndarray of subsurface storage values, spanning all layers (bottom to top), for the current DataAccessor object data.

  27. data.surface_storage
    return

    An ny by nx ndarray of surface storage values for the current DataAccessor object data.

  28. data.wtd
    return

    An ny by nx ndarray of water table depth values (measured from the top) for the current DataAccessor object data.

  29. 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 ndarray of CLM output for the given field and layer on the current DataAccessor object data.

  30. 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')

  31. data.clm_output_diagnostics
    return

    String filepath to CLM output diagnostics file for the current DataAccessor object data.

  32. data.clm_output_eflx_lh_tot
    return

    An ndarray containing CLM eflx_lh_tot data for the current DataAccessor object data.

  33. data.clm_output_eflx_lwrad_out
    return

    An ndarray containing CLM eflx_lwrad_out data for the current DataAccessor object data.

  34. data.clm_output_eflx_sh_tot
    return

    An ndarray containing CLM eflx_sh_tot data for the current DataAccessor object data.

  35. data.clm_output_eflx_soil_grnd
    return

    An ndarray containing CLM eflx_soil_grnd data for the current DataAccessor object data.

  36. data.clm_output_qflx_evap_grnd
    return

    An ndarray containing CLM qflx_evap_grnd data for the current DataAccessor object data.

  37. data.clm_output_qflx_evap_soi
    return

    An ndarray containing CLM qflx_evap_soi data for the current DataAccessor object data.

  38. data.lm_output_qflx_evap_tot
    return

    An ndarray containing CLM qflx_evap_tot data for the current DataAccessor object data.

  39. data.clm_output_qflx_evap_veg
    return

    An ndarray containing CLM qflx_evap_veg data for the current DataAccessor object data.

  40. data.clm_output_qflx_infl
    return

    An ndarray containing CLM qflx_infl data for the current DataAccessor object data.

  41. data.clm_output_qflx_top_soil
    return

    An ndarray containing CLM qflx_top_soil data for the current DataAccessor object data.

  42. data.clm_output_qflx_tran_veg
    return

    An ndarray containing CLM qflx_tran_veg data for the current DataAccessor object data.

  43. data.clm_output_swe_out
    return

    An ndarray containing CLM swe_out data for the current DataAccessor object data.

  44. data.clm_output_t_grnd
    return

    An ndarray containing CLM t_grnd data for the current DataAccessor object data.

  45. data.clm_forcing(name)
    param name

    Forcing type you’re interested in

    return

    An ndarray containing CLM forcing data for the given name and forcing timestep set on the current DataAccessor object data.

  46. data.clm_forcing_dswr
    return

    An ndarray containing CLM forcing data for Downward Visible or Short-Wave radiation [W/m2] for the forcing timestep set on the current DataAccessor object data.

  47. data.clm_forcing_dlwr
    return

    An ndarray containing CLM forcing data for Downward Infa-Red or Long-Wave radiation [W/m2] for the forcing timestep set on the current DataAccessor object data.

  48. data.clm_forcing_apcp
    return

    An ndarray containing CLM forcing data for Precipitation rate [mm/s] for the forcing timestep set on the current DataAccessor object data.

  49. data.clm_forcing_temp
    return

    An ndarray containing CLM forcing data for Air temperature [K] for the forcing timestep set on the current DataAccessor object data.

  50. data.clm_forcing_ugrd
    return

    An ndarray containing CLM forcing data for West-to-East or U-component of wind [m/s] for the forcing timestep set on the current DataAccessor object data.

  51. data.clm_forcing_vgrd
    return

    An ndarray containing CLM forcing data for South-to-North or V-component of wind [m/s] for the forcing timestep set on the current DataAccessor object data.

  52. data.clm_forcing_press
    return

    An ndarray containing CLM forcing data for Atmospheric Pressure [pa] for the forcing timestep set on the current DataAccessor object data.

  53. data.clm_forcing_spfh
    return

    An ndarray containing CLM forcing data for Water-vapor specific humidity [kg/kg] for the forcing timestep set on the current DataAccessor object data.

  54. 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 current DataAccessor object data.

  55. data.clm_map_latitude
    return

    Data corresponding to Solver.CLM.Vegetation.Map.Latitude key set on the ParFlow run for the current DataAccessor object data.

  56. data.clm_map_longitude
    return

    Data corresponding to Solver.CLM.Vegetation.Map.Longitude key set on the ParFlow run for the current DataAccessor object data.

  57. data.clm_map_sand
    return

    Data corresponding to Solver.CLM.Vegetation.Map.Sand key set on the ParFlow run for the current DataAccessor object data.

  58. data.clm_map_clay
    return

    Data corresponding to Solver.CLM.Vegetation.Map.Clay key set on the ParFlow run for the current DataAccessor object data.

  59. data.clm_map_color
    return

    Data corresponding to Solver.CLM.Vegetation.Map.Color key set on the ParFlow run for the current DataAccessor object data.