geowatch.tasks.cold.tile_processing_kwcoco module

This is step 2/4 in predict.py and the step that runs pycold

SeeAlso

  • predict.py

  • prepare_kwcoco.py

  • tile_processing_kwcoco.py

  • export_cold_result_kwcoco.py

  • assemble_cold_result_kwcoco.py

This script is for running COLD algorithm with kwcoco dataset. See original code: ~/code/pycold/src/python/pycold/imagetool/tile_processing.py

class geowatch.tasks.cold.tile_processing_kwcoco.TileProcessingKwcocoConfig(*args, **kwargs)[source]

Bases: DataConfig

The docstring will be the description in the CLI help

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

default = {'b_c2': <Value(True)>, 'cm_interval': <Value(60)>, 'conse': <Value(6)>, 'method': <Value('COLD')>, 'n_cores': <Value(None)>, 'prob': <Value(0.99)>, 'rank': <Value(None)>, 'reccg_path': <Value(None)>, 'stack_path': <Value(None)>}
geowatch.tasks.cold.tile_processing_kwcoco.tile_process_main(cmdline=1, **kwargs)[source]
Parameters:
  • n_cores (type=int) – _description_

  • stack_path (_type_) – _description_

  • reccg_path (_type_) – _description_

  • method (_type_) – _description_

  • year_lowbound (_type_) – _description_

  • year_highbound (_type_) – _description_

  • b_c2 (_type_) – _description_

  • cmdline (int, optional) – _description_. Defaults to 1.

Example

>>> # xdoctest: +REQUIRES(env:TEST_COLD)
>>> from geowatch.tasks.cold.tile_processing_kwcoco import tile_process_main
>>> from geowatch.tasks.cold.tile_processing_kwcoco import *
>>> import ubelt as ub
>>> kwargs= dict(
>>>    rank = 1,
>>>    n_cores = 1,
>>>    stack_path = ub.Path('/gpfs/scratchfs1/zhz18039/jws18003/kwcoco/stacked/KR_R001'),
>>>    reccg_path = ub.Path('/gpfs/scratchfs1/zhz18039/jws18003/kwcoco/reccg/KR_R001'),
>>>    method = 'COLD',
>>>    b_c2 = True,
>>>    prob = 0.99,
>>>    conse = 6,
>>>    cm_interval = 60,
>>> )
>>> cmdline=0
>>> tile_process_main(cmdline, **kwargs)
geowatch.tasks.cold.tile_processing_kwcoco.read_json_metadata(stacked_path)[source]
geowatch.tasks.cold.tile_processing_kwcoco.is_finished_cold_blockfinished(reccg_path, nblocks)[source]

check if the COLD algorithm finishes all blocks

Parameters:
  • reccg_path (str) – the path that save COLD results

  • nblocks (int) – the block number

Returns:

True if all block finished

Return type:

bool

geowatch.tasks.cold.tile_processing_kwcoco.get_stack_date(block_x, block_y, stack_path, year_lowbound=0, year_highbound=0, nband=8)[source]
Parameters:
  • block_x – block id at x axis

  • block_y – block id at y axis

  • stack_path – stack path

  • year_lowbound – ordinal data of low bounds of selection date range

  • year_highbound – ordinal data of upper bounds of selection date range

Returns:

img_tstack, img_dates_sorted img_tstack - 3-d array (block_width * block_height, nband, nimage)

Return type:

Tuple

geowatch.tasks.cold.tile_processing_kwcoco.reading_start_dates_nmaps(stack_path, year_lowbound, year_highbound, cm_interval)[source]
Parameters:
  • stack_path (str) – stack_path for saving starting_last_dates.txt

  • cm_interval (interval) – day interval for outputting change magnitudes

Returns:

(starting_date, n_cm_maps) starting_date - starting date is the first date of the whole dataset, n_cm_maps - the number of change magnitudes to be outputted per pixel per band

Return type:

Tuple

geowatch.tasks.cold.tile_processing_kwcoco.is_finished_assemble_cmmaps(cmmap_path, n_cm, starting_date, cm_interval)[source]
Parameters:
  • cmmap_path – the path for saving change magnitude maps

  • n_cm – the number of change magnitudes outputted per pixel

  • starting_date – the starting date of the whole dataset

  • cm_interval – the day interval for outputting change magnitudes

Returns:

True -> assemble finished

Return type:

bool