Giter VIP home page Giter VIP logo

subseasonal_toolkit's Introduction

Subseasonal Forecasting Toolkit

The subseasonal_toolkit package provides implementations of the subseasonal forecasting ABC model of

Adaptive Bias Correction for Subseasonal Forecasting
Soukayna Mouatadid, Paulo Orenstein, Genevieve Flaspohler, Judah Cohen, Miruna Oprescu, Ernest Fraenkel, and Lester Mackey. Nature Communications. June 2023.

@article{mouatadid2023adaptive,
	author = {Mouatadid, Soukayna and Orenstein, Paulo and Flaspohler, Genevieve and Cohen, Judah and Oprescu, Miruna and Fraenkel, Ernest and Mackey, Lester},
	journal = {Nature Communications},
	number = {1},
	pages = {3482},
	title = {Adaptive bias correction for improved subseasonal forecasting},
	volume = {14},
	year = {2023}}

and the machine learning models and meteorological baselines of

SubseasonalClimateUSA: A Dataset for Subseasonal Forecasting and Benchmarking
Soukayna Mouatadid, Paulo Orenstein, Genevieve Flaspohler, Miruna Oprescu, Judah Cohen, Franklyn Wang, Sean Knight, Maria Geogdzhayeva, Sam Levang, Ernest Fraenkel, and Lester Mackey. Advances in Neural Information Processing Systems (NeurIPS). Dec. 2023.

@inproceedings{mouatadid2023toolkit,
 author = {Soukayna Mouatadid, Paulo Orenstein, Genevieve Flaspohler, Miruna Oprescu, Judah Cohen, Franklyn Wang, Sean Knight, Maria Geogdzhayeva, Sam Levang, Ernest Fraenkel, and Lester Mackey},
 booktitle = {Advances in Neural Information Processing Systems},
 editor = {A. Globerson and K. Saenko and M. Hardt and S. Levine},
 publisher = {Curran Associates, Inc.},
 title = {SubseasonalClimateUSA: A Dataset for Subseasonal Forecasting and Benchmarking},
 volume = {36},
 year = {2023}
}

System Requirements

This package has been tested with the following operating system and Python pairings:

  • macOS Monterey 12.6.3 with Python 3.9.12
  • Linux CentOS 7 with Python 3.7.9

A complete list of Python dependencies can be found in setup.cfg; these dependencies are required upon installation.

Getting Started

  • Install the subseasonal toolkit package: pip install subseasonal-toolkit
    • Installation completed in under 1 minute with pip 22.2.2 on a 2021 MacBook Pro with 16 GB of RAM running macOS Monterey version 12.6.3.
  • Define the environment variable $SUBSEASONALDATA_PATH to point to your desired data directory; any data files needed by a model will be read from, saved to, or synced with this directory
  • Run the following demo which generates and evaluates Raw CFSv2 precipitation forecasts across the contiguous U.S. for the 2018-2021 std_paper_forecast evaluation period of "Adaptive Bias Correction for Subseasonal Forecasting": python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m raw_cfsv2 --task us_tmp2m_1.5x1.5_34w
    • This demo ran to completion in 7 minutes with Python 3.9.12 on a 2021 MacBook Pro with 16 GB of RAM running macOS Monterey version 12.6.3.
    • Expected outputs
      • A forecast folder models/cfsv2pp/submodel_forecasts/cfsv2pp-debiasFalse_years12_margin0_days1-1_leads15-15_lossmse/us_tmp2m_1.5x1.5_34w/ containing daily forecast files from 20180101 through 20211231
      • A metrics folder eval/metrics/raw_cfsv2/submodel_forecasts/cfsv2pp-debiasFalse_years12_margin0_days1-1_leads15-15_lossmse/us_tmp2m_1.5x1.5_34w/ containing 6 evaluation metrics:
        • lat_lon_error-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5
        • lat_lon_rmse-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5
        • lat_lon_skill-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5
        • rmse-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5
        • score-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5
        • skill-us_tmp2m_1.5x1.5_34w-std_paper_forecast.h5

Generating Model Forecasts

The following examples demonstrate how to generate contiguous US forecasts for the target dates evaluated in "Adaptive Bias Correction for Subseasonal Forecasting" or "SubseasonalClimateUSA: A Dataset for Subseasonal Forecasting and Benchmarking" using each implemented model.

  • ABC-CCSM4:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each CCSM4++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m ccsm4pp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m ccsm4
  • ABC-CFSv2:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each CFSv2++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m cfsv2pp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m cfsv2
  • ABC-ECMWF:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each ECMWF++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m ecmwfpp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m ecmwf
  • ABC-FIMr1p1:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each FIMr1p1++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m fimr1p1pp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m fimr1p1
  • ABC-GEFS:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each GEFS++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m gefspp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m gefs
  • ABC-GEMS:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each GEMS++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m gemspp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m gems
  • ABC-GEOS_v2p1:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each GEOS_v2p1++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m geos_v2p1pp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m geos_v2p1
  • ABC-NESM:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each NESM++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m nesmpp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m nesm
  • ABC-SubX:
    • Generate predictions for each Climatology++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Generate predictions for each SubX++ model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m subx_meanpp
    • Run ABC python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -a -m subx_mean
  • AutoKNN: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m autoknn
  • CCSM4++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m ccsm4pp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m ccsm4pp
  • CFSv2++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m cfsv2pp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m cfsv2pp
  • Climatology: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m climatology
  • Climatology++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m climpp
  • Debiased CFSv2: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_cfsv2
  • Debiased ECMWF Control and Ensemble:
    • First, select your desired source (control or ensemble) for debiasing and forecasting in subseasonal_toolkit/models/deb_ecmwf/selected_submodel.json by setting the forecast_with and debias_with keys as described in deb_ecmwf.ipynb.
    • Then, run the selected model: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_ecmwf
  • Debiased LOESS CFSv2: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_loess_cfsv2
  • Debiased LOESS ECMWF: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_loess_ecmwf
  • Debiased Quantile Mapping CFSv2: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_quantile_cfsv2
  • Debiased Quantile Mapping ECMWF: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_quantile_ecmwf
  • Debiased SubX: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m deb_subx_mean
  • ECMWF++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m ecmwfpp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m ecmwfpp
  • FIMr1p1++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m fimr1p1pp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m fimr1p1pp
  • GEFS++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m gefspp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m gefspp
  • GEM++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m gempp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m gempp
  • GEOS++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m geos_v2p1pp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m geos_v2p1pp
  • Informer: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m informer
  • LocalBoosting:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -u -b -m localboosting
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper -u -tu -m localboosting
  • MultiLLR: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m multillr
  • N-BEATS: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m nbeats
  • NN-A: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m nn-a
  • Online Ensemble: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m online_learning
  • Persistence: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m persistence
  • Persistence++ CCSM4: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m perpp_ccsm4
  • Persistence++ CFSv2: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m perpp_cfsv2
  • Persistence++ ECMWF: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m perpp_ecmwf
  • Persistence++ FIMr1p1: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_fimr1p1 -u -e
  • Persistence++ GEFS: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_gefs -u -e
  • Persistence++ GEM: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_gem -u -e
  • Persistence++ GEOS_v2p1: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_geos_v2p1 -u -e
  • Persistence++ NESM: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_nesm -u -e
  • Persistence++ SubX: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m perpp_subx_mean -u -e
  • Prophet: python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m prophet
  • Raw CCSM4: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m raw_ccsm4
  • Raw CFSv2: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m raw_cfsv2
  • Raw ECMWF: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -u -e -m raw_ecmwf
  • Raw FIMr1p1: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_fimr1p1 -u -e
  • Raw GEFS: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_gefs -u -e
  • Raw GEM: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_gem -u -e
  • Raw GEOS_v2p1: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_geos_v2p1 -u -e
  • Raw NESM: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_nesm -u -e
  • Raw SubX: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -m raw_subx_mean -u -e
  • Salient2:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -u -b -m salient2
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper -u -tu -m salient2
  • SubX++:
    • First generate predictions for each model configuration python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m subx_meanpp
    • Then select a model configuration using the tuner python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -tu -m subx_meanpp
  • Uniform Ensemble: python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m linear_ensemble

For Developers

Installation

After cloning this repository, install from source in editable mode using pip install -e . in this directory or pip install -e path/to/directory from another directory.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

subseasonal_toolkit's People

Contributors

franklynwang avatar geflaspohler avatar lmackey avatar mouatadid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

subseasonal_toolkit's Issues

help for running climatology model

After installing the subseasonal_toolkit package and downloading the relevant data, the example files were able to run successfully and produced six evaluation output files. But when I run the code "python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m climatology", there are some errors :
'''
Running generate predictions with arguments models=['climatology'], deadline_date=None,target_date=std_paper_forecast, cmd_prefix=python, usa=True, task=None,tuned=False, d2p=False, bulk=False, ecmwf=True, abc=False
Model climatology, us_tmp2m_1.5x1.5, 12w.
Traceback (most recent call last):
File "/Users/mac/Tools/miniconda3/envs/cf/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/mac/Tools/miniconda3/envs/cf/lib/python3.9/runpy.py", line 87, in run_code
exec(code, run_globals)
File "/Users/mac/Tools/subseasonal_toolkit-main/subseasonal_toolkit/generate_predictions.py", line 166, in
json_args = json.load(params_file)[f'{gt_id}
{horizon}']
KeyError: 'us_tmp2m_1.5x1.5_12w'
'''
I found the content of (subseasonal_toolkit/models/climatology/selected_submodel.json) the json document is empty.

help for running climatology++ model

Thank you for your response, I run the code "python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m climatology" successfully. But when I run the code "python -m subseasonal_toolkit.generate_predictions -t std_paper_eval -e -u -b -m climpp", there are some errors. What am I not doing right? (results: The "models" folder appears to be empty, with no "climpp" folder present. Additionally, there seem to be several empty folders within the "eval/metrics/climpp/submodel_forecasts/" directory .)

Here are the errors:
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support
Job 1013b638-dd36-a445-4ded-cd7ac72abe54 has started
Log file is located at: /home/metraffic/.azcopy/1013b638-dd36-a445-4ded-cd7ac72abe54.log

100.0 %, 0 Done, 0 Failed, 0 Pending, 0 Total, 2-sec Throughput (Mb/s): 0

Job 1013b638-dd36-a445-4ded-cd7ac72abe54 Summary
Files Scanned at Source: 1
Files Scanned at Destination: 1
Elapsed Time (Minutes): 0.0333
Number of Copy Transfers for Files: 0
Number of Copy Transfers for Folder Properties: 0
Total Number Of Copy Transfers: 0
Number of Copy Transfers Completed: 0
Number of Copy Transfers Failed: 0
Number of Deletions at Destination: 0
Total Number of Bytes Transferred: 0
Total Number of Bytes Enumerated: 0
Final Job Status: Completed

elapsed: 5.7759055979549885s
Getting metrics for 2015-01-01 00:00:00
20150101
Warning: models/climpp/submodel_forecasts/climpp-lossrmse_yearsall_margin10/us_tmp2m_1.5x1.5_12w/us_tmp2m_1.5x1.5_12w-20150101.h5 does not exist; skipping
Getting metrics for 2015-01-02 00:00:00

Originally posted by @babybearming in #4 (comment)

A issue about how to get start

When I run the code of 'python -m subseasonal_toolkit.generate_predictions -t std_paper_forecast -e -u -m nn-a' in the cmd. After running for a while ,I see the program has an error of subprocess.CalledProcessError: Command 'azcopy' returned non-zero exit status 2. And when Getting metrics ,models\nn-a\submodel_forecasts\nn——a_12w_e10001\us_tmp2m_1.5x1.5_12w/us_tmp2m_1.5x1.5_12w-20180101.h5 does not exist; skipping
I want to ask if "I want to ask if my approach about getting started is wrong. Did I miss any steps.

Informer baseline runtime error

Dear authors, thank you for your work and sharing!
When I run informer.ipynb and informer.py, I encounter a shape incompatibility error in the model's forward, and to solve it I locate at subseasonal_toolkit/models/informer/data/data_loader.py line 329:

df_raw = data_loaders.get_ground_truth("us_" + self.target, sync=False).reset_index()

After I change "us_" + self.target to the variable gt_id, it works. May I ask whether my modification is correct? Please feel free to point out any of my misunderstanding of the dataset or toolkit. Many thanks!

Missing selected_submodel.json for Informer

When I tried to run Informer inference via python -m subseasonal_toolkit.generate_predictions -t std_paper -u -m informer as shown in README, I got the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'MY_ROOT/subseasonal_toolkit/subseasonal_toolkit/models/informer/selected_submodel.json'

Any idea? Thanks for helping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.