Functions that implement basic functionality that will be used in the library.

Util functions

A set of functions that provide usefull functionality

filter_files[source]

filter_files(files, include=[], exclude=[])

Filter list of files using a list of strings to inculde and/or exclude

ls[source]

ls(x, recursive=False, include=[], exclude=[])

List files in folder, if recursive is True also list subfolders

hdf_attr_check[source]

hdf_attr_check(attr, hdf, default)

Check if attribute is in hdf_attr_dict and return default

dict2json[source]

dict2json(data:dict, file)

Writes json file from dict

Examples:

path = Path('.')
path.ls()
[Path('.gitattributes'),
 Path('.ipynb_checkpoints'),
 Path('.last_checked'),
 Path('00_core.ipynb'),
 Path('01_geo.ipynb'),
 Path('02_data.ipynb'),
 Path('03_models.ipynb'),
 Path('04_predict.ipynb'),
 Path('04b_nrt.ipynb'),
 Path('04c_historical.ipynb'),
 Path('05_train.ipynb'),
 Path('06_cli.ipynb'),
 Path('07_web.ipynb'),
 Path('data'),
 Path('hide'),
 Path('historicalPT'),
 Path('images'),
 Path('index.ipynb'),
 Path('tutorial.australia2020.ipynb'),
 Path('tutorial.australia2020_100m.ipynb')]
path = Path('.')
path.ls(include=['.ipynb'])
[Path('.ipynb_checkpoints'),
 Path('00_core.ipynb'),
 Path('01_geo.ipynb'),
 Path('02_data.ipynb'),
 Path('03_models.ipynb'),
 Path('04_predict.ipynb'),
 Path('04b_nrt.ipynb'),
 Path('04c_historical.ipynb'),
 Path('05_train.ipynb'),
 Path('06_cli.ipynb'),
 Path('07_web.ipynb'),
 Path('index.ipynb'),
 Path('tutorial.australia2020.ipynb'),
 Path('tutorial.australia2020_100m.ipynb')]
path = Path('.')
path.ls(include=['.ipynb'], exclude=['_checkpoints'])
[Path('00_core.ipynb'),
 Path('01_geo.ipynb'),
 Path('02_data.ipynb'),
 Path('03_models.ipynb'),
 Path('04_predict.ipynb'),
 Path('04b_nrt.ipynb'),
 Path('04c_historical.ipynb'),
 Path('05_train.ipynb'),
 Path('06_cli.ipynb'),
 Path('07_web.ipynb'),
 Path('index.ipynb'),
 Path('tutorial.australia2020.ipynb'),
 Path('tutorial.australia2020_100m.ipynb')]

monthlen[source]

monthlen(year, month)

Gives lenght of the month

year = 2000
month = 2
monthlen(year, month)
29

class InOutPath[source]

InOutPath(input_path:str, output_path:str, mkdir=True)

Keeps track of an input and a output path. Creates paths if they don't exist and mkdir=True

InOutPath.src[source]

Shortcut to input_path

InOutPath.dst[source]

Shortcut to output_path

class ProjectPath[source]

ProjectPath(path:Path, config_dir='config', ladsweb_dir='ladsweb', hotspots_dir='hotspots', dataset_dir='dataset', outputs_dir='outputs', web_dir='web')

ProjectPath.create_dirs[source]

ProjectPath.create_dirs(paths_list)

Create directories in list.

paths = ProjectPath('data')
test_eq(sorted([o.name for o in paths.path.iterdir()]), 
        ['config', 'dataset', 'hotspots', 'ladsweb', 'outputs', 'web'])