ocssw
V2022
|
Classes | |
class | CustomUnpickler |
Functions | |
def | ignore_warnings (func) |
def | find_wavelength (k, waves, validate=True, tol=5) |
def | closest_wavelength (k, waves, validate=True, tol=5) |
def | safe_int (v) |
def | get_wvl (nc_data, key) |
def | line_messages (messages, nbars=1) |
def | get_labels (wavelengths, slices, n_out=None) |
def | compress (path, overwrite=False) |
def | uncompress (path, overwrite=False) |
def | store_pkl (filename, output) |
def | read_pkl (filename) |
def | cache (filename, recache=False) |
def | using_feature (args, flag) |
def | split_data (x_data, other_data=[], n_train=0.5, n_valid=0, seed=None, shuffle=True) |
def | mask_land (data, bands, threshold=0.1, verbose=False) |
def | get_tile_data (filenames, sensor, allow_neg=True, rhos=False, anc=False, **kwargs) |
def | generate_config (args, create=True, verbose=True) |
def | get_data (args) |
Function Documentation
◆ cache()
def MDN.utils.cache | ( | filename, | |
recache = False |
|||
) |
◆ closest_wavelength()
def MDN.utils.closest_wavelength | ( | k, | |
waves, | |||
validate = True , |
|||
tol = 5 |
|||
) |
◆ compress()
def MDN.utils.compress | ( | path, | |
overwrite = False |
|||
) |
◆ find_wavelength()
def MDN.utils.find_wavelength | ( | k, | |
waves, | |||
validate = True , |
|||
tol = 5 |
|||
) |
◆ generate_config()
Create a config file for the current settings, and store in a folder location determined by certain parameters: MDN/model_loc/sensor/model_lbl/model_uid/config "model_uid" is computed within this function, but a value can also be passed in manually via args.model_uid in order to allow previous MDN versions to run.
◆ get_data()
def MDN.utils.get_data | ( | args | ) |
◆ get_labels()
def MDN.utils.get_labels | ( | wavelengths, | |
slices, | |||
n_out = None |
|||
) |
Helper to get label for each target output. Assumes that any variable in <slices> which has more than a single slice index, will have an associated wavelength label. Usage: wavelengths = [443, 483, 561, 655] slices = {'bbp':slice(0,4), 'chl':slice(4,5), 'tss':slice(5,6)} n_out = 5 labels = get_labels(wavelengths, slices, n_out) # labels -> ['bbp443', 'bbp483', 'bbp561', 'bbp655', 'chl']
◆ get_tile_data()
◆ get_wvl()
def MDN.utils.get_wvl | ( | nc_data, | |
key | |||
) |
◆ ignore_warnings()
def MDN.utils.ignore_warnings | ( | func | ) |
◆ line_messages()
def MDN.utils.line_messages | ( | messages, | |
nbars = 1 |
|||
) |
Allow multiline message updates via tqdm. Need to call print() after the tqdm loop, equal to the number of messages which were printed via this function (to reset cursor). nbars is the number of tqdm bars the line messages come after. Usage: nbars = 2 for i in trange(5): for j in trange(5, leave=False): messages = [i, i/2, i*2] line_messages(messages, nbars) for _ in range(len(messages) + nbars - 1): print()
◆ mask_land()
def MDN.utils.mask_land | ( | data, | |
bands, | |||
threshold = 0.1 , |
|||
verbose = False |
|||
) |
◆ read_pkl()
def MDN.utils.read_pkl | ( | filename | ) |
◆ safe_int()
def MDN.utils.safe_int | ( | v | ) |
◆ split_data()
def MDN.utils.split_data | ( | x_data, | |
other_data = [] , |
|||
n_train = 0.5 , |
|||
n_valid = 0 , |
|||
seed = None , |
|||
shuffle = True |
|||
) |
◆ store_pkl()
def MDN.utils.store_pkl | ( | filename, | |
output | |||
) |
◆ uncompress()
def MDN.utils.uncompress | ( | path, | |
overwrite = False |
|||
) |
◆ using_feature()
def MDN.utils.using_feature | ( | args, | |
flag | |||
) |
Certain hyperparameter flags have a yet undecided default value, which means there are two possible names: using the feature, or not using it. This method simply combines both into a single boolean signal, which indicates whether to add the feature. For example: use_flag = hasattr(args, 'use_ratio') and args.use_ratio no_flag = hasattr(args, 'no_ratio') and not args.no_ratio signal = use_flag or no_flag # if true, we add ratios becomes signal = using_feature(args, 'ratio') # if true, we add ratios