geoips.xarray_utils package#
Submodules#
geoips.xarray_utils.data module#
Utilities for manipulating xarray Datasets and DataArrays.
- geoips.xarray_utils.data.get_lat_lon_points(checklat, checklon, diff, sect_xarray, varname, drop=False)[source]#
Pull values from xarray Datasets in specified geographic location.
Return points a given distance around a specified lat/lon location, from xarray Datasets.
- Parameters:
checklat (float) – latitude of interest
checklon (float) – longitude of interest
diff (float) – check +- diff of latitude and longitude
sect_xarray (Dataset) – xarray dataset containing ‘latitude’ ‘longitude’ and varname variables
varname (str) – variable name of data array to use for returning data values
- Returns:
min value in range
max value in range
and number of points in range
- Return type:
float, float, int
- geoips.xarray_utils.data.get_lat_lon_points_numpy(checklat, checklon, diff, lat_array, lon_array, data_array)[source]#
Pull values from numpy arrays in specified geographic location.
Return points a given distance around a specified lat/lon location, from numpy arrays.
- Parameters:
checklat (float) – latitude of interest
checklon (float) – longitude of interest
diff (float) – check +- diff of latitude and longitude
lat_array (ndarray) – numpy ndarray of latitude locations - same shape as lon_array and data_array
lon_array (ndarray) – numpy ndarray of longitude locations - same shape as lat_array and data_array
data_array (ndarray) – numpy ndarray data values - same shape as lat_array and lon_array
- Returns:
min value in range
max value in range
and number of points in range
- Return type:
float, float, int
- geoips.xarray_utils.data.get_sectored_xarrays(xobjs, area_def, varlist, get_bg_xarrays=False, check_center=True, drop=False)[source]#
Get all xarray objects sectored to area_def.
Return primary dataset, as well as VIS/IR overlay datasets.
- geoips.xarray_utils.data.get_vis_ir_bg(sect_xarray)[source]#
Find matching vis/ir background for data in sect_xarray.
- geoips.xarray_utils.data.sector_xarray_dataset(full_xarray, area_def, varnames, lon_pad=3, lat_pad=0, verbose=False, hours_before_sector_time=18, hours_after_sector_time=6, drop=False)[source]#
Use the xarray to appropriately sector out data by lat/lon and time.
- geoips.xarray_utils.data.sector_xarray_spatial(full_xarray, extent_lonlat, varnames, lon_pad=3, lat_pad=0, verbose=False, drop=False)[source]#
Sector an xarray object spatially. If full_xarray is None, return None.
- Parameters:
full_xarray (xarray.Dataset) – xarray object to sector spatially
extent_lonlat (list of float) – Area to sector: [MINLON, MINLAT, MAXLON, MAXLAT]
varnames (list of str) – list of variable names that should be sectored based on ‘time’
drop (bool) – Specify whether to remove points with no coverage (rather than masking)
- Returns:
if full_xarray is None, return None,
else return resulting xarray Dataset.
- Return type:
xarray.Dataset
- geoips.xarray_utils.data.sector_xarray_temporal(full_xarray, mindt, maxdt, varnames, verbose=False, drop=False)[source]#
Sector an xarray object temporally. If full_xarray is None, return None.
- Parameters:
full_xarray (xarray.Dataset) – xarray object to sector temporally
mindt (datetime.datetime) – minimum datetime of desired data
maxdt (datetime.datetime) – maximum datetime of desired data
varnames (list of str) – list of variable names that should be sectored based on ‘time’, mindt, maxdt
- Returns:
if full_xarray is None, return None
return full original xarray object if ‘time’ is not included in varnames list
else, return sectored xarray object with only the desired times, specified by mindt and maxdt
- Return type:
xarray Dataset, or None
geoips.xarray_utils.time module#
Utils to handle time stamp information within xarray objects.
- geoips.xarray_utils.time.get_datetime_from_datetime64(dt64)[source]#
Get a python datetime object from a numpy datetime64 object.
- Parameters:
dt64 (numpy.datetime64') – numpy.datetime64 object
- Returns:
Python datetime object
- Return type:
datetime.datetime
Notes
Backwards compatible with numpy versions
- geoips.xarray_utils.time.get_max_from_xarray_time(xarray_obj, varname)[source]#
Get the maximum time as a datetime object from xarray object.
- Parameters:
xarray_obj (xarray.Dataset or xarray.DataArray) – xarray object from which to extract the maximum time
varname (str) – Timestamp variable name from which to extract the maximum time
- Returns:
Python datetime.datetime object representing maximum time of the Dataset or DataArray
- Return type:
datetime.datetime
- geoips.xarray_utils.time.get_min_from_xarray_time(xarray_obj, varname)[source]#
Get the minimum time as a datetime object from xarray object.
- Parameters:
xarray_obj (xarray.Dataset or xarray.DataArray) – xarray object from which to extract the minimum time
varname (str) – Timestamp variable name from which to extract the minimum time
- Returns:
Python datetime.datetime object representing minimum time of the Dataset or DataArray
- Return type:
datetime.datetime
Module contents#
Geoips xarray utils init file.