pybob.bob_tools¶
pybob.bob_tools is a collection of the tools that didn’t really fit other places.
-
pybob.bob_tools.bin_data(bins, data2bin, bindata, mode='mean', nbinned=False)[source]¶ Place data into bins based on a secondary dataset, and calculate statistics on them.
Parameters: - bins (array-like) – array-like structure indicating the bins into which data should be placed.
- data2bin (array-like) – data that should be binned.
- bindata (array-like) – secondary dataset that decides how data2bin should be binned. Should have same size/shape as data2bin.
- mode (str) – How to calculate statistics of binned data. One of ‘mean’, ‘median’, ‘std’, ‘max’, or ‘min’.
- nbinned (bool) – Return a second array, nbinned, with number of data points that fit into each bin. Default is False.
Returns binned, nbinned: calculated, binned data with same size as bins input. If nbinned is True, returns a second array with the number of inputs for each bin.
-
pybob.bob_tools.doy2mmdd(year, doy, string_out=True, outform='%Y/%m/%d')[source]¶ Return a string or a datetime object given a year and a day of year.
Parameters: - year (int) – Year of the input date, e.g.,
2018. - doy (int) – Day of the year of the input date, e.g.,
1for 1 Jan. - string_out (bool) – Return a string (True) or a datetime object (False). Default is True.
- outform (str) – Format for string to return. Default is %Y/%m/%d, or 2018/01/01 for 1 January 2018.
Returns date: datetime.datetime or string representation of the input date.
>>> bt.doy2mmdd(2018, 1, string_out=True) `2018/01/01`
>>> bt.doy2mmdd(2018, 1, string_out=False) datetime.datetime(2018, 1, 1, 0, 0)
- year (int) – Year of the input date, e.g.,
-
pybob.bob_tools.mkdir_p(out_dir)[source]¶ Add bash mkdir -p functionality to os.makedirs.
Parameters: out_dir – directory to create.
-
pybob.bob_tools.mmdd2doy(year, month, day, string_out=True)[source]¶ Return a string or an int representing a day of year, given a date.
Parameters: - year (int) – Year of the input date, e.g.,
2018. - mm (int) – Month of the year of the input date, e.g.,
1for Jan. - dd (int) – Day of the month of the input date.
- string_out (bool) – Return a string (True) or an int (False). Default is True.
Returns doy: day of year representation of year, month, day
>>> bt.mmdd2doy(2018, 1, 1, string_out=True) `1`
- year (int) – Year of the input date, e.g.,