Skip to content

Commit

Permalink
Coding session w/ Anna & Lilli
Browse files Browse the repository at this point in the history
  • Loading branch information
jejjohnson committed Mar 18, 2024
1 parent 5a78886 commit a8d9273
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 7 deletions.
26 changes: 26 additions & 0 deletions config/example/download.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# input

# REGION
region:
lat_min: -130
lat_max: -90
lon_min: -15
lon_max: 5

# PERIOD
period:
start_date: '2018-10-01'
start_time: ...
end_date: '2018-10-31'
end_time: ...

# EXTRAS
cloud_mask: True

# PATH
save_dir: ./goes

defaults:
- _self_
- satellite: goes.yaml

Empty file added config/example/geoprocess.yaml
Empty file.
Empty file added config/example/main.yaml
Empty file.
Empty file added config/example/patch.yaml
Empty file.
Empty file added config/example/preprocess.yaml
Empty file.
15 changes: 15 additions & 0 deletions config/example/satellite/goes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
__target__: rs_tools.OTHER_WRAPPER_SCRIPT
start_date: ${download.start_date}
end_date: ${download.end_date}
save_dir: ${download.save_dir}
cloud_mask: ${download.cloud_mask}
daily_window_t0: '14:00:00'
daily_window_t1: '20:00:00'
time_step: '4:00:00'
satellite_number: 16
instrument: 'ABI'
processing_level: 'L1b'
data_product: 'Rad'
domain: 'F'
bands: 'all'
check_bands_downloaded: False
Empty file added config/main.yaml
Empty file.
40 changes: 40 additions & 0 deletions rs_tools/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import hydra
from loguru import logger
from omegaconf import OmegaConf, DictConfig


@hydra.main(config_path="../config", config_name="main", version_base="1.3")
def main(cfg):
lib = hydra.utils.instantiate(cfg...)

logger.debug(f"Choosing stage...")
if cfg.stage == "download":
for satellite in cfg.download.keys():
# instantiate download function
# pick parameters
# download
logger.debug(f"starting download script...")
raise NotImplementedError()
elif cfg.stage == "preprocess":
logger.debug(f"starting preprocessing script...")
raise NotImplementedError()
# elif cfg.stage == "train":
# logger.debug(f"starting training script...")
# raise NotImplementedError()
# elif cfg.stage == "inference":
# logger.debug(f"starting inference script...")
# raise NotImplementedError()
# elif cfg.stage == "evaluation":
# logger.debug(f"starting evaluation script...")
# raise NotImplementedError()
else:
raise ValueError(f"Unrecognized stage: {cfg.stage}")



def main(config: DictConfig):
pass

if __name__ == "__main__":
main()

1 change: 0 additions & 1 deletion scripts/pipeline/goes/download_goes.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def download(
logger.info("Done!")

# TODO: Create DataFrame
# TODO: save MODIS-TERRA filenames to CSV?
# TODO: save GOES-16 filenames to CSV?
logger.info("Finished Script...")

Expand Down
24 changes: 23 additions & 1 deletion scripts/pipeline/modis/download_modis.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,27 @@ def download(
logger.info("Finished Script...")


# ALOT OF HYDRA META INFORMATION
# Create a configuration associated with the above function (cf next cell)
import hydra_zen
import hydra

main_config = hydra_zen.builds(download, populate_full_signature=True)

# Wrap the function to accept the configuration as input
zen_endpoint = hydra_zen.zen(download)

#Store the config
store = hydra_zen.ZenStore()
store(main_config, name='download_modis')
store.add_to_hydra_store(overwrite_ok=True)

# Create CLI endpoint
api_endpoint = hydra.main(
config_name='download_modis', version_base="1.3", config_path=None
)(zen_endpoint)

if __name__ == '__main__':
typer.run(download)
# HYDRA ENDPOINT
# typer.run(download)
api_endpoint()
5 changes: 0 additions & 5 deletions scripts/pipeline/modis/preprocess_modis.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class GeoProcessingParams:
class MODISGeoProcessing:
resolution: float = 1_000 # km
read_path: str = "./"
patch_size: int = 256
stride_size: int = 256
save_path: str = "./"

@property
Expand Down Expand Up @@ -103,11 +101,8 @@ def load_modis_files(self, satellite: str="aqua"):


def preprocess_modis(
modis_save_dir: str = "./",
resolution: float = 1000,
read_path: str = "./",
patch_size: int = 256,
stride_size: int = 256,
save_path: str = "./"
):
"""
Expand Down

0 comments on commit a8d9273

Please sign in to comment.