Skip to content

MODIS burned area product NetCDFs are not recreated for new year ranges [BUG] #129

Description

@natshoff

Bug Description

NetCDFs from MODIS tiles are not regenerated if date range changes. For example, if I run firedpy on Spain for 2020-2024 and then again for 2004-2006, I will get an error from firedpy trying to use the cached NetCDFs which do not have 2004-2006.

To Reproduce

Steps to reproduce the behavior:

  1. Open a test directory
  2. Run firedpy -i, choose date range one (e.g. 2020-2024)
  3. Run firedpy again from the same test directory, choosing a new independent data range (e.g. 2004-2006)

Expected Behavior

Redownload MODIS tiles and create NetCDSs for updated date range.

Environment Details

  • OS: Windows
  • Python version: 3.14
  • firedpy version: V2 (tw/install)
  • Region/Country: Any (I used Spain)

Data Processing Details

  • Date range: 2020-2024 and 2004-2006
  • Spatial extent: Spain

Error Information

Note: this is from running the second date range e.g. 2004-2006.

Firedpy run submitted with the following user-supplied values:
    project_directory = C:\Users\naho5798\Documents\FIRED_dev\test_fired
    interactive = True
Using the following default values:
    project_name = 'new_env'
    country = 'spain'
    tiles = None
    shape_file = None
    start_year = 2004
    end_year = 2007
    spatial_param = 8  # pixels (nominally ~3,704 m but varies by location)
    temporal_param = 3  # days
    daily = False
    shape_type = 'gpkg'  # GeoPackage
    eco_region_level = 1  # Level I - Least Detailed
    eco_region_type = 'na'  # North American Ecoregions (Omernick, 1987)
    land_cover_type = 1  # International Geosphere-Biosphere Programme (IGBP) scheme
    full_csv = False
    n_cores = 1
    cleanup = False
Confirm parameters and proceed? [y/N]: y
INFO - 2026-03-02 16:20:17,296 [run.py:152] : Running firedpy for years 2004 to 2007 on MODIS tiles: None.
INFO - 2026-03-02 16:20:17,297 [run.py:169] : Collecting MODIS burn data.
INFO - 2026-03-02 16:20:19,444 [data_classes.py:582] : Getting burn data using EarthAccess for tiles: None
INFO - 2026-03-02 16:20:19,444 [data_classes.py:583] : Date range: 2004-01-01 to 2007-12-31
INFO - 2026-03-02 16:20:19,445 [data_classes.py:587] : Searching for MCD64A1 granules: 2004-01-01 - 2007-12-31
100%|██████████████████████████████████████████████████████████████████████| 5/5 [00:03<00:00,  1.41it/s]
INFO - 2026-03-02 16:20:23,686 [data_classes.py:597] : Processing tile: h16v06
INFO - 2026-03-02 16:20:23,686 [data_classes.py:601] : Found 48 granules for tile h16v06
INFO - 2026-03-02 16:20:23,693 [data_classes.py:597] : Processing tile: h17v04
INFO - 2026-03-02 16:20:23,693 [data_classes.py:601] : Found 48 granules for tile h17v04
INFO - 2026-03-02 16:20:23,694 [data_classes.py:597] : Processing tile: h17v05
INFO - 2026-03-02 16:20:23,694 [data_classes.py:601] : Found 48 granules for tile h17v05
INFO - 2026-03-02 16:20:23,695 [data_classes.py:597] : Processing tile: h18v04
INFO - 2026-03-02 16:20:23,695 [data_classes.py:601] : Found 48 granules for tile h18v04
INFO - 2026-03-02 16:20:23,696 [data_classes.py:597] : Processing tile: h18v05
INFO - 2026-03-02 16:20:23,696 [data_classes.py:601] : Found 48 granules for tile h18v05
INFO - 2026-03-02 16:20:23,698 [data_classes.py:464] : Downloading to h16v06 data to C:\Users\naho5798\Documents\FIRED_dev\test_fired\rasters\burn_area\hdfs\h16v06
INFO - 2026-03-02 16:20:34,612 [data_classes.py:470] : Downloaded h16v06 data (48 files)
INFO - 2026-03-02 16:20:34,612 [data_classes.py:464] : Downloading to h17v04 data to C:\Users\naho5798\Documents\FIRED_dev\test_fired\rasters\burn_area\hdfs\h17v04
INFO - 2026-03-02 16:20:47,956 [data_classes.py:470] : Downloaded h17v04 data (48 files)
INFO - 2026-03-02 16:20:47,958 [data_classes.py:464] : Downloading to h17v05 data to C:\Users\naho5798\Documents\FIRED_dev\test_fired\rasters\burn_area\hdfs\h17v05
INFO - 2026-03-02 16:21:05,040 [data_classes.py:470] : Downloaded h17v05 data (48 files)
INFO - 2026-03-02 16:21:05,046 [data_classes.py:464] : Downloading to h18v04 data to C:\Users\naho5798\Documents\FIRED_dev\test_fired\rasters\burn_area\hdfs\h18v04
INFO - 2026-03-02 16:21:42,992 [data_classes.py:470] : Downloaded h18v04 data (48 files)
INFO - 2026-03-02 16:21:42,994 [data_classes.py:464] : Downloading to h18v05 data to C:\Users\naho5798\Documents\FIRED_dev\test_fired\rasters\burn_area\hdfs\h18v05
INFO - 2026-03-02 16:21:59,599 [data_classes.py:470] : Downloaded h18v05 data (48 files)
INFO - 2026-03-02 16:21:59,599 [data_classes.py:638] : EarthAccess burn data download completed!
INFO - 2026-03-02 16:21:59,600 [data_classes.py:763] : Building netcdf files for tiles ['h16v06', 'h17v04', 'h17v05', 'h18v04', 'h18v05']
100%|█████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00, 796.09it/s] 
INFO - 2026-03-02 16:21:59,608 [data_classes.py:649] : Created NetCDF for tile(s) ['h16v06', 'h17v04', 'h17v05', 'h18v04', 'h18v05']
INFO - 2026-03-02 16:22:01,792 [run.py:193] : Building event perimeter geometries.
INFO - 2026-03-02 16:22:01,792 [model_classes.py:907] : Building fire event perimeters.
  0%|                                                                              | 0/5 [00:01<?, ?it/s] 
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\naho5798\AppData\Local\miniconda3\Scripts\firedpy.exe\__main__.py", line 7, in <module>  
    sys.exit(cli())
             ~~~^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\click\core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\click\core.py", line 1406, in main   
    rv = self.invoke(ctx)
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\click\core.py", line 1269, in invoke 
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\click\core.py", line 824, in invoke  
    return callback(*args, **kwargs)
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\cli.py", line 300, in cli
    _ = fired(**params)
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\run.py", line 194, in fired
    gdf = models.build_events()
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\model_classes.py", line 842, in build_events
    event_perimeters = self.classify_events()
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\model_classes.py", line 914, in classify_events
    out = self.process_perimeters(nc_fpath)
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\model_classes.py", line 1303, in process_perimeters
    event_grid = EventGrid(
        nc_fpath=nc_fpath,
    ...<6 lines>...
        shape_file=self.shape_file
    burns = self.mask_array(burns, self.shape_file)
  File "C:\Users\naho5798\Documents\FIRED_dev\firedpy\firedpy\model_classes.py", line 426, in mask_array
    array["value"] *= mask_array
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\xarray\core\_typed_ops.py", line 778, in __imul__
    return self._inplace_binary_op(other, operator.imul)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\xarray\core\dataarray.py", line 4934, in _inplace_binary_op
    f(self.variable, other_variable)
    ~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\xarray\core\_typed_ops.py", line 1206, in __imul__
    return self._inplace_binary_op(other, operator.imul)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\naho5798\AppData\Local\miniconda3\Lib\site-packages\xarray\core\variable.py", line 2465, in _inplace_binary_op
    self.values = f(self_data, other_data)
                  ~^^^^^^^^^^^^^^^^^^^^^^^
ValueError: non-broadcastable output operand with shape (0,1,1) doesn't match the broadcast shape (0,2400,2400)

Additional Context

I really doubt this error will come up much, but we should probably create some error handling around it. We could add time stamps to the netcdfs (e.g. h16v06_2004-2006.nc) to know if they should be regenerated or if the cached version could be used in order to fix this.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions