wavy.utils
utility fcts for the verification
Attributes
Classes
Suppress stdout. |
Functions
|
Retrieves PID and prints it |
|
Calculate the great circle distance between two points |
|
Calculate the great circle distance between two points |
|
Calculate the great circle distance between two points |
|
Computes the running mean with various configurations. |
|
Computes the running mean with various configurations. |
|
running mean using convolution |
|
Conducts a simple naive bootstrap: |
|
Removes entries in both time series that are NaN. |
|
Rounds to nearest hour by adding a timedelta hour if minute >= 30 |
|
Rounds to nearest hour by adding a timedelta hour if minute >= 30 |
|
mv files to sub-folders of year and month |
|
Sort AVISO files according to year and month. |
|
Sort L3 files according to year and month. |
|
Sort L3 s6a files according to year and month. |
|
Sort L3 files according to year and month. |
|
Sort L2P and L3 files according to year and month. |
|
Sort L2 files according to year and month. |
|
Recursively finds size of objects |
|
|
|
Find index/indices of unfiltered time series that fall |
|
fct for collocating times within a given twin as tolerance |
|
fct to create forecast date vector |
|
|
|
|
|
Finds and returns path of file given templates and keywords and date. |
|
Takes a dict with nested lists and dicts, |
|
Creates a path given templates and keywords and date. |
|
|
fct to convert angles from meteorological convention to |
|
|
|
|
|
|
|
|
computes requested variable from dispersion relation in deep water |
|
|
|
|
|
|
|
|
|
remove all results for wavelengths below given llim |
|
fct to compute quantiles for given ts |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pulse limited footprint radius according to Chelton et al. 2001 |
|
Module Contents
- wavy.utils.variable_def
- wavy.utils.grab_PID()
Retrieves PID and prints it
- wavy.utils.haversineP(lon1, lat1, lon2, lat2)
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
- wavy.utils.haversine_np(lon1, lat1, lon2, lat2)
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
All args must be of equal length.
- wavy.utils.haversineA(lon1, lat1, lon2, lat2)
Calculate the great circle distance between two points on the earth (specified in decimal degrees) Note: lon1,lat1,lon2, and lat2 can be lists
- wavy.utils.runmean_old(vec, win, mode=None, weights=None) tuple
Computes the running mean with various configurations.
- Args:
vec (numpy.ndarray | list): array of values to me smoothed win (int): window length mode (str): string: left, centered, right weights (numpy.ndarray | list): weights (same size as win)
- Returns:
- tuple (out (numpy.ndarray), std (numpy.ndarray)):
array of smoothed values and std deviation
- wavy.utils.runmean(vec, win, mode=None, weights=None) tuple
Computes the running mean with various configurations.
- Args:
vec (numpy.ndarray | list): array of values to me smoothed win (int): window length mode (str): string: left, centered, right weights (numpy.ndarray | list): weights (same size as win)
- Returns:
- tuple (out (numpy.ndarray), std (numpy.ndarray)):
array of smoothed values and std deviation
- wavy.utils.runmean_conv(x: numpy.ndarray, win: int, mode='flat') numpy.ndarray
running mean using convolution
- Args:
x (numpy.ndarray): array of values to me smoothed win (int): window length mode (str): which type of smoothing window to pic
- Notes:
https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html
- Returns:
out (numpy array): array of smoothed values
- Raises:
ValueError: for wrong dimension of x and wrong windowsize
- wavy.utils.bootstr(a, reps)
Conducts a simple naive bootstrap:
- input: - a is time series of length n
reps (number of repetitions)
- output: - an array of dim n x m where
m is the number of repetitions
indices of draws
- wavy.utils.marginalize(a, b=None)
Removes entries in both time series that are NaN.
input: np.arrays with np.nan for invalids
- wavy.utils.hour_rounder(t)
Rounds to nearest hour by adding a timedelta hour if minute >= 30
- wavy.utils.hour_rounder_pd(times)
Rounds to nearest hour by adding a timedelta hour if minute >= 30
- wavy.utils.sort_files(dirpath, filelst, product, sat)
mv files to sub-folders of year and month
- wavy.utils.sort_aviso_l2p(dirpath: str, filelst: list)
Sort AVISO files according to year and month.
- wavy.utils.sort_cmems_l3_nrt(dirpath: str, filelst: list, sat: str)
Sort L3 files according to year and month.
- wavy.utils.sort_cmems_l3_s6a(dirpath: str, filelst: list, sat: str)
Sort L3 s6a files according to year and month.
- wavy.utils.sort_cmems_l3_my(dirpath: str, filelst: list, sat: str)
Sort L3 files according to year and month.
- wavy.utils.sort_cci(dirpath: str, filelst: list)
Sort L2P and L3 files according to year and month.
- wavy.utils.sort_eumetsat_l2(dirpath: str, filelst: list)
Sort L2 files according to year and month.
- wavy.utils.get_size(obj, seen=None)
Recursively finds size of objects
From: https://goshippo.com/blog/measure-real-size-any-python-object/
- wavy.utils.find_included_times_pd(unfiltered_t: list, sdate: datetime.datetime, edate: datetime.datetime) list
- wavy.utils.find_included_times(unfiltered_t: list, target_t=None, sdate=None, edate=None, twin=0) list
Find index/indices of unfiltered time series that fall within a tolerance time window around the target time or within a time window specified by sdate and edate
- wavy.utils.collocate_times(unfiltered_t: list, target_t=None, sdate=None, edate=None, twin=None) list
fct for collocating times within a given twin as tolerance target_t and unfiltered_t need to be lists of datetime objects twin is in minutes.
returns idx
- wavy.utils.flatten
- wavy.utils.make_fc_dates(sdate: datetime.datetime, edate: datetime.datetime, date_incr_unit: str, date_incr: int) list
fct to create forecast date vector
- wavy.utils.system_call(command: str)
- wavy.utils.make_subdict(strsublst, class_object=None, class_object_dict=None)
- wavy.utils.get_pathtofile(pathlst, strsublst, subdict, date)
Finds and returns path of file given templates and keywords and date.
- wavy.utils.finditem(search_dict, field)
Takes a dict with nested lists and dicts, and searches all dicts for a key of the field provided.
- wavy.utils.make_pathtofile(tmppath, strsublst, subdict, date=None)
Creates a path given templates and keywords and date.
- wavy.utils.find_direction_convention(filevarname, ncdict)
- wavy.utils.convert_meteorologic_oceanographic(alpha)
fct to convert angles from meteorological convention to oceanographic and vice versa.
- class wavy.utils.NoStdStreams(stdout=None, stderr=None)
Bases:
object
Suppress stdout. if argument is verbose stdout is shown, e.g.: with NoStdStreams(verbose)
https://codereview.stackexchange.com/questions/25417/ is-there-a-better-way-to-make-a-function-silent-on-need
- devnull
- _stdout
- _stderr
- __enter__()
- __exit__(exc_type, exc_value, traceback)
- wavy.utils.get_item_parent(ncdict, item, attr)
- wavy.utils.get_item_child(ncdict, item)
- wavy.utils.parse_date(indate)
- wavy.utils.dispersion_deep_water(T=None, k=None, l=None, cp=None, cg=None)
computes requested variable from dispersion relation in deep water
- wavy.utils.dispersion_shallow_water(l=None, h=None, T=None)
- wavy.utils.dispersion_intermediate_water(l=None, h=None, T=None)
- wavy.utils.calc_deep_water_T(l=None)
- wavy.utils.calc_shallow_water_T(l=None, h=None)
- wavy.utils.wave_length_mask_swim(ds, llim=50, ulim=2000)
remove all results for wavelengths below given llim
- wavy.utils.compute_quantiles(ts, lq)
fct to compute quantiles for given ts
- param:
ts - iterable of ts lq - iterable of quantiles
- return:
qA - numpy array of quantiles
- wavy.utils.get_obsdict(obstype)
- wavy.utils.find_tagged_obs(tags, obstype)
- wavy.utils.expand_nID_for_sensors(nID, obstype)
- wavy.utils.date_dispatcher(date, date_incr='d', incr=1)
- wavy.utils.date_next_hour(date, incr)
- wavy.utils.date_next_day(date, incr)
- wavy.utils.date_next_month(date, incr)
- wavy.utils.date_next_year(date, incr)
- wavy.utils.footprint_pulse_limited_radius(Hs: float, h: float, tau: float) float
Pulse limited footprint radius according to Chelton et al. 2001 as referenced in coastal altimtery book p. 458, EQ 17.1
Footprint size across track depends on: - significant wave height - satellite specs:
height over ground (h)
pulse duration (tau)
- wavy.utils.build_xr_ds(var: tuple, varnames: tuple)