Prototype application for GCM bias-correction and downscaling

Overview

dodola

Prototype application for GCM bias-correction and downscaling

This is an unstable prototype. This is under heavy development.

Features

  • Nothing! The unit tests might work if you're lucky.

Example

After installing, use from the commandline with:

dodola biascorrect  
   
    
    

    
   
  
 

See more help with:

dodola --help

Installation

You shouldn't! This will likely run within a Docker container in a production environment on cloud infrastructure. But, to install with pip:

pip install git+https://github.com/ClimateImpactLab/dodola
Comments
  • 360 days calendar support

    360 days calendar support

    This PR adds support for 360-day calendar GCM input data. The changes are :

    1. I added the function xclim_convert_360day_calendar_interpolate to dodola.core. This function takes a 360-day calendar time indexed dataset and converts its calendar to a chosen target calendar type, offering the option to interpolate the inserted missing values.

    2. This functionality is now used by default with linear interpolation in standardize_gcm to handle the GCM data we currently use that has a 360-day calendar.

    3. I also added a test for this in dodola.tests.test_core, which required to add a calendar option in the _timeseriesfactory function.

    This PR solves this downscaleCMIP6 issue.

    enhancement 
    opened by emileten 12
  • update precip units in cmip6 cleanup to be pint-compatible

    update precip units in cmip6 cleanup to be pint-compatible

    As of now we convert precip units to mm day -1 and this is not pint-compatible. We need to update the units to mm/day for precip for both CMIP6 cleaning and ERA-5. This is because xclim now checks units using pint.

    bug 
    opened by dgergel 9
  • Add QDM workflow components

    Add QDM workflow components

    This PR ports some hairy quantile delta mapping (QDM) bias correction stuff. The additions are "hairy" because the these steps of the workflow have some eccentricities in Azure and currently scale in production with Argo Workflows (and not dask).

    More specifically this PR:

    Adds dodola train-qdm

    which is run like

    dodola train-qdm -h "az://historical.zarr" -r "az://reference.zarr" -v "tasmax" \
        -o "az://qdm.zarr" --kind "additive"
    

    This trains a xclim.sdba.adjustment.QuantileDeltaMapping to our spec and dumps it to a Zarr Store.

    Adds dodola apply-qdm

    which can be run like

    dodola apply-qdm \
        --simulation "az://future-simulation.zarr" \
        --qdm "az://qdm.zarr" \
        --year 2026 \
        --variable "tasmax" \
        -o "/mnt/outadjusted-simulation.nc"
    

    Note, this applies QDM to a simulation for a single year of adjusted values output to a NetCDF4 file on the local disk.

    Close #66

    enhancement 
    opened by brews 9
  • bump max polar DTR to 110 & compute stats in error msgs

    bump max polar DTR to 110 & compute stats in error msgs

    In this PR:

    • NorESM2-MM failing due to 107 DTR at (75.5, 102.5) and (76.5, 105.5), both of which are in faaaaar northern Russia along the arctic sea. This bumps the check tolerance to 110C.
    • Also computes data checks and converts to floats prior to data tests so they display cleanly in assertion errors and so they aren't computed twice when assertions fail.
    • Finally, drops (if X is not None) tests, which never evaluate to False.
    opened by delgadom 8
  • precip units temporary replacement

    precip units temporary replacement

    This solves #125, (precip units incompatible with the xclim pint registry)

    1. added an units_replacement parameter to each services.apply-* and services.train-* function, to (optionally) temporarily swap the variable units attribute for a chosen string, during bias correction and downscaling.

    2. this option is used in each upstream cli function if variable=='pr' to temporarily swap units with "mm/day".

    @brews (1) is general (variable agnostic) in case we want to make use of that in other cases, but (2) doesn't give an option and uses it for precip -- so that we don't need to change workflow templates now. I didn't write a unit test, it sounded like a lot of code to me for what it is. I am not fully aware of our test coverage ambitions though. Let me know.

    bug 
    opened by emileten 8
  • "regrid" drops dataset attributes

    Anytime we call dodola.core.xesmf_regrid, the output data is missing attributes from the input data. It would be great if we could keep — or merge — attrs from input data.

    bug 
    opened by brews 8
  • first attempt at adding basic bias correction code and fixing tests

    first attempt at adding basic bias correction code and fixing tests

    This PR adds in some super basic bias correction code as well as a dependency on a forked version of scikit-downscale with an interim fix for a current bug in PointwiseDownscaler.

    enhancement 
    opened by dgergel 8
  • Add analog downscaling prototype

    Add analog downscaling prototype

    This PR adds the analog-inspired, quantile-preserving downscaling method as a new service. It is split up into two services, train_aiqpd and adjust_aiqpd and is based on the implementation of QDM. This is intended to supersede spatial disaggregation as the main mode of downscaling in dodola for the time being.

    Basic CLI interface is:

    dodola train_aiqpd /path/to/coarse_reference.zarr \
    /path/to/fine_reference.zarr 
    --out /path/to/trained_afs.zarr \
    --v "tasmax", 
    --k "+"
    
    dodola apply_aiqpd /path/to/biascorrected.zarr \
    /path/to/trainedafs/zarr \
    -- year 2026
     --v "tasmax" 
    --out /path/to/trained_afs.zarr \
    

    closes #73

    enhancement 
    opened by dgergel 6
  • Remove conda package pins

    Remove conda package pins

    • [ ] closes #xxxx
    • [x] tests added / passed
    • [x] docs reflect changes
    • [x] entry in CHANGELOG.md

    Upate container conda environment package pins. We are pretty behind and they're in need of an update.

    enhancement 
    opened by brews 5
  • Update package setup, README, HISTORY/CHANGELOG to new system

    Update package setup, README, HISTORY/CHANGELOG to new system

    Migrate dodola package setup, build, configuration from setup.py to pyproject.toml and setup.cfg. This follows updated best practices in python packaging.

    • Migrates README from RST to Markdown.
    • Migrate HISTORY.rst to CHANGELOG.md, following https://keepachangelog.com.
    documentation enhancement 
    opened by brews 5
  • Hack fix to validate OOM errors

    Hack fix to validate OOM errors

    • [x] closes #126
    • [x] tests added / passed
    • [x] docs reflect changes
    • [x] entry in CHANGELOG.md

    Fixes dodola validate-dataset failing with out-of-memory errors on small workers without external dask cluster. This was especially a problem on quality-control checks to 0.25 degree grid input data.

    This solution is somewhat hackish in that we're reading and subsetting the input data to year available year in dodola.services — essentially refactoring the larger validation flow from dodola.core to dodola.services so that we can keep all the storage I/O implementation details out of dodola.core. This is an adaptation of the solution to used in this temporary fix.

    bug 
    opened by brews 4
  • Unit tests are very very slow

    Unit tests are very very slow

    Unit tests run in CI have become very very slow. The can take about 15 minutes to complete.

    I suspect dodola.services.validate() using dask.delayed is the culprit. Dask was used here as a hack to work around memory problems (see #126). The drawback to this hack has been that simple unit tests on Datasets covering a long time range take much more time to run.

    If this is the case I see two options:

    1. Re-write validation to work around the original memory problems in #126 while also making unit tests complete faster. i.e. replace the hack solution with a "real" solution.
    2. Find and refactor the one or two long-running unit tests so that they test the same behavior, but run faster.
    bug help wanted 
    opened by brews 0
  • Port Diana Gergel's QPLAD from CIL xclim fork

    Port Diana Gergel's QPLAD from CIL xclim fork

    This adds a port of @dgergel's QuantilePreservingAnalogDownscaling for QPLAD downscaling.

    This is ported from a ClimateImpactLab fork of xclim.

    Porting this code lets us run QPLAD in dodola without depending on pip-installing an old fork of xclim, instead, installing xclim from conda-forge. A xclim=0.30.1 dependency from conda-forge was added to environment.yaml because I think this is the last version the xclim fork synced from https://github.com/Ouranosinc/xclim. v0.30.1 of xclim was released Oct 1st, 2021. Currently, the latest version of xclim is v0.36.0.

    • [ ] closes #xxxx
    • [x] tests added / passed
    • [x] docs reflect changes
    • [ ] entry in CHANGELOG.md
    enhancement 
    opened by brews 1
  • Add label for code source to container images

    Add label for code source to container images

    We should put a label in the Dockerfile to add a URL to the code repository.

    Basically add this

    LABEL org.opencontainers.image.source="https://github.com/ClimateImpactLab/dodola"
    

    to Dockerfile.

    documentation enhancement help wanted 
    opened by brews 0
  • Validation checks should throw new ValidationFailed-like, not AssertionError

    Validation checks should throw new ValidationFailed-like, not AssertionError

    At the moment all checks to validate output data are done using assert. It would be great if we could get these to throw a custom error (like ValidationError or some subclass of this) instead.

    People often run python can be run with assertions disabled, and this would disable a key behavior in these functions. Worse still is that validation code would still quietly run and "pass" data with no indication that checks are not being performed.

    This addition could also make it easier for people to catch and handle certain types of validation problems, with more helpful error messages.

    bug help wanted 
    opened by brews 1
  • Test that `dodola.services.validate` actually fails bad data

    Test that `dodola.services.validate` actually fails bad data

    We test dodola.services.validate in dodola.tests.test_services.test_validation() for the "happy path" (well-behaved data), but it would be great if we could test to ensure validation correctly catches each of the conditions that it's supposed to catch.

    I think I've mentioned this in a few previous PRs, but I'm putting it here so we dont' forget.

    enhancement help wanted 
    opened by brews 0
  • dodola.services.get_attrs() is missing logging.

    dodola.services.get_attrs() is missing logging.

    Logging for dodola.services.get_attrs() is extremely quiet. All of the major services in dodola.services get decorated with @log_service so that it logs service entrance and exit. It looks like dodola.services.get_attrs() is missing the decorator and thus doesn't log properly.

    https://github.com/ClimateImpactLab/dodola/blob/696938abe7e7e2bc6221b36a885f41a4544677a7/dodola/services.py#L509

    bug help wanted 
    opened by brews 0
Releases(v0.19.0)
  • v0.19.0(Mar 25, 2022)

    Added

    • Add badge for current release DOI to README. (@brews)

    Changed

    • Significant update to container/package environment pins. (PR #183, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.18.0(Mar 3, 2022)

    Added

    • Add basic CI/CD test and build status badges to README. (PR #182, @brews)

    Fixed

    • Fix dodola validate-dataset OOM on small workers without dask-distributed. (PR #181, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.17.0(Feb 17, 2022)

    Changed

    • Increase max allowed tasmin, tasmax in services.validate to 377 K for UKESM1-0-LL. (PR #180, @brews)

    Fixed

    • Move in-memory data loading where it is needed for 360-days calendar conversion in clean-cmip6 (PR #179, @emileten)
    Source code(tar.gz)
    Source code(zip)
  • v0.16.2(Feb 15, 2022)

  • v0.16.1(Jan 27, 2022)

    Fixed

    • Fix the wetday frequency correction so that different replacement values are used, rather than a single one (PR #174, PR #176, @emileten, @delgadom).
    Source code(tar.gz)
    Source code(zip)
  • v0.16.0(Jan 18, 2022)

    Added

    • Improve README.md. (PR #169, @brews)

    Changed

    • Remove duplicated service-level logging info lines of code introduced by PR #148 (PR #168, @emileten)
    • Decrease validation temperature range min to 130 (PR #170, @emileten)
    Source code(tar.gz)
    Source code(zip)
  • v0.15.1(Dec 29, 2021)

  • v0.15.0(Dec 28, 2021)

    Added

    • Add maximum precipitation adjustment service that applies a "ceiling" or "cap" to precipitation values above a user-defined threshold. (PR #164, @dgergel)

    Changed

    • Increase max precipitation allowed by validation to 3000 mm. (PR #164, @dgergel)
    • Update wet day frequency correction to incorporate method additions from Hempel et al 2013. (PRs #162 and #159, @dgergel)
    • Floor and ceiling for DTR. (PR #163 @emileten)
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Dec 21, 2021)

    Changed

    • Update wet day frequency correction to include small negative values in correction and to limit the correction range to the threshold * 10 ^ -2. (PR #158, @dgergel)
    • Update package setup, README, HISTORY/CHANGELOG to new system. (PR #154, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Dec 18, 2021)

    • Update diurnal temperature range (DTR) validation to differentiate min DTR accepted value for CMIP6 vs bias corrected and downscaled data inputs (PR #155, @dgergel)
    • Update diurnal temperature range (DTR) validation to differentiate polar and non-polar regions (PR #153, @dgergel)
    • Fix rechunk error when converting 360 days calendars. (#149, PR #151, @brews)
    • Remove cruft code. Removes dodola commands biascorrect, downscale, buildweights along with corresponding functions in dodola.services and dodola.core. (PR #152, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.12.0(Dec 9, 2021)

    • Add 360 days calendar support (PR #144, @emileten)
    • Add an option to temporarily replace the target variable units in dodola services and use in CLI dodola for precip (PR #143, @emileten)
    • Add diurnal temperature range (DTR) correction for small DTR values below 1 (converts them to 1) (PR #145, @dgergel)
    Source code(tar.gz)
    Source code(zip)
  • v0.11.1(Dec 3, 2021)

    • Decrease allowed timesteps for bias corrected/downscaled files in validation to allow models that only go through 2099 (PR #146, @dgergel)
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Dec 1, 2021)

    • Increase validation temperature range max to 360 (PR #142, @dgergel)
    • Distinguish missing from excess timesteps in timesteps validation (PR #140, @emileten)
    • Add post wet day correction option in CLI dodola (PR #141 @emileten)
    Source code(tar.gz)
    Source code(zip)
  • v0.10.0(Nov 22, 2021)

    • Add additional tests for dodola.core.*_analogdownscaling functions. (PR #136, @dgergel, @brews)
    • Update dtr range check max to allow up to 70 C. (PR #138, @brews, @dgergel)
    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Nov 15, 2021)

    • Fix attrs missing from services.apply_qplad output Datasets. (#135, @brews)
    • Add --root-attrs-json-file to prime-qplad-output-zarrstore, apply-qplad, prime-qdm-output-zarrstore, apply-qdm. (PR #134, @brews)
    • Add dodola get-attrs command. (PR #133, @brews)
    • Upgrade Docker base image to continuumio/miniconda3:4.10.3. (PR #132, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Nov 11, 2021)

    • AIQPD has been renamed "Quantile-Preserving, Localized Analogs Downscaling" (QPLAD). AIQPD-named commands have been switch to QPLAD. This is backward compatibility breaking. (PR #131, @brews)
    • Add AIQPD output Zarr priming (prime-aipqd-output-zarrstore), input slicing, region writing, attrs merging, and multi-year processing. This breaks backwards compatibility for apply-aiqpd and its services and core functions. See the pull request for additional details. (PR #130, @brews)
    • Similarly, add QDM output Zarr priming (prime-qdm-output-zarrstore), region writing, attrs merging, and multi-year processing. This breaks backwards compatibility for apply-qdm and its services and core functions. See the pull request for additional details. (PR #129, @brews)
    • Make logging slightly more chatty by default. (PR #129, @brews)
    • Add pre-training slicing options to train-qdm and train-aiqpd. (PR #123, PR #128, @brews)
    • Quick fix validation reading entire zarr store for check. (PR #124, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Nov 2, 2021)

    • Update xclim version to 0.30.1, this updates the Train/Adjust API for QDM and AIQPD and requires units attributes for all QDM and AIQPD inputs. (PR #119, @dgergel)
    • Add global validation, includes new service validate for validating cleaned CMIP6, bias corrected and downscaled data for historical and future time periods. (PR #118, @dgergel)
    • Regrid copies input Dataset attrs metadata to output (#116). (PR #121, @brews)
    • Upgrade dask to 2021.10.0 to cover https://nvd.nist.gov/vuln/detail/CVE-2021-42343. (PR #122, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Sep 8, 2021)

    • Add AIQPD downscaling method to options. Also updates xclim dependency to use the CIL-fork and "@add_analog_downscaling" branch, with 0.28.1 of xclim merged in. This supersedes the BCSD downscaling service. (PR #98, PR #115, @dgergel)
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Aug 5, 2021)

    • Bump environment xarray to v0.19.0. Note this change has breaking changes in Zarr Store I/O. (PR #109, @brews)
    • Add --cyclic option to regrid cli and services. (PR #108, @brews)
    • Add papermill, intake-esm to Docker environment. (PR #106, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Jul 13, 2021)

  • v0.4.0(Jul 9, 2021)

    • Add include-quantiles flag to apply_qdm to allow for including quantile information in bias corrected output. (PR #95, @dgergel)
    • Add precipitation unit conversion to standardize_gcm. (PR #94, @dgergel)
    • Add astype argument to regrid. (PR #92, @brews)
    • Make dodola container's default CMD. (PR #90, @brews)
    • Improve subprocess and death handling in Docker container. (PR #90, @brews)
    • Fix bug in train_quantiledeltamapping accounting for endpoints. (#87, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jun 17, 2021)

    • Significant updates to container environment: Python 3.9, xarray, adlfs, xesmf, dask, and fsspec. (PR #74, PR #75, PR #76, PR #77, PR #84 @brews)
    • Update buildweights service to add support for regridding to domain file. Not backwards compatible. (PR #67, @dgergel)
    • Add downscaling service. Currently support BCSD spatial disaggregation as implemented in scikit-downscale. (PR #65, @dgergel)
    • Remove stdout buffering from container runs, add IO debug logging. (PR #72, @brews)
    • Add bias-correction quantile delta mapping (QDM) components to support Argo Workflows. New commands added: dodola train-qdm and dodola apply-qdm. (PR #70, @brews)
    • Fix CMIP6 clean to better handle coords vs dims. (PR #81, @brews)
    • Add wet day frequency correction service. Wet day frequency implemented as described in Cannon et al., 2015. New command added: dodola correct-wetday-frequency. (PR #78, @dgergel)
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Apr 23, 2021)

    • Fix TypeError from dodola rechunk. (PR #63, @brews)
    • Switch to pure fsspec-style URLs for data inputs. Added support for GCS buckets and S3 storage. Switch to fsspec backend settings to collect storage authentication. Because of this users likely will need to change the environment variables used to pass in storage credentials. dodola.services no longer require the storage argument. (PR #61, @brews)
    • Switch to simple xarray-based rechunking to workaround to instability from our use of rechunker. This change breaks the CLI for dodola rechunk, removing the -v/--variable and -m/--maxmemory options. The change also breaks the dodola.services.rechunk() signature, removing the max_mem argument and the target_chunks argument is now a mapping {coordinate_name: chunk_size}. (PR #60, @brews)
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Apr 15, 2021)

Owner
Climate Impact Lab
Code, tools, and data from the Climate Impact Lab
Climate Impact Lab
Код файнтюнинга оригинального CLIP на русский язык

О чем репозиторий В этом репозитории представлен способ файтюнить оригинальный CLIP на новый язык Почему модель не видит женщину и откуда на картинке

Valentina Biryukova 7 Feb 06, 2022
Data on COVID-19 (coronavirus) cases, deaths, hospitalizations, tests • All countries • Updated daily by Our World in Data

COVID-19 Dataset by Our World in Data Find our data on COVID-19 and its documentation in public/data. Documentation Data: complete COVID-19 dataset Da

Our World in Data 5.5k Jan 03, 2023
Multi-Process / Censorship Detection

Multi-Process / Censorship Detection

Baris Dincer 2 Dec 22, 2021
Repository voor verhalen over de woningbouw-opgave in Nederland

Analyse plancapaciteit woningen In deze notebook zetten we cijfers op een rij om de woningbouwplannen van Nederlandse gemeenten in kaart te kunnen bre

Follow the Money 10 Jun 30, 2022
Calculate the efficient frontier

关于 代码主要参考Fábio Neves的文章,你可以在他的文章中找到一些细节性的解释

Wyman Lin 104 Nov 11, 2022
A comparison of mesh generators.

This repository creates meshes of the same domains with multiple mesh generators and compares the results.

Nico Schlömer 29 Dec 12, 2022
Simple Crud Python vs MySQL

Simple Crud Python vs MySQL The idea came when I was studying MySQ... A desire to create a python program that can give access to a "localhost" databa

Lucas 1 Jan 21, 2022
A nonebot2 plugin, send news information in a picture form.

A nonebot2 plugin, send news information in a picture form.

幼稚园园长 7 Nov 18, 2022
Analisador de strings feito em Python // String parser made in Python

Este é um analisador feito em Python, neste programa, estou estudando funções e a sua junção com "if's" e dados colocados pelo usuário. Neste código,

Dev Nasser 1 Nov 03, 2021
Example of my qtile config using the gruvbox colorscheme.

QTILE config Example of my qtile config using the gruvbox colorscheme. unicodes.py unicodes.py returns a widget.TextBox with a unicode. Currently it c

Imanuel Febie 31 Jan 02, 2023
AIO solution for SSIS students

ssis.bit AIO solution for SSIS students Hardware CircuitPython supports more than 200 different boards. Locally available is the TTGO T8 ESP32-S2 ST77

3 Jun 05, 2022
A (hopefully) considerably copious collection of classical cipher crackers

ClassicalCipherCracker A (hopefully) considerably copious collection of classical cipher crackers Written in Python3 (and run with PyPy) TODOs Write a

Stanley Zhong 2 Feb 22, 2022
A Desktop application for the signalum python library

Signalum Desktop A Desktop application on the Signalum Python Library/CLI Tool. The Signalum Desktop application is an attempt to develop a single too

BISOHNS 35 Feb 15, 2021
A streamlit app for exploring image search results from HuggingPics

title emoji colorFrom colorTo sdk app_file pinned huggingpics-explorer 🤗 blue red streamlit app.py false huggingpics-explorer A streamlit app for exp

Nathan Raw 4 Sep 10, 2022
Python version of RocketLeague-Dropshot-Calculated-shot

Python version of RocketLeague-Dropshot-Calculated-shot. This is just to demo around and a tool I used to develop the actual plugin.

JareBear 1 Jan 14, 2022
python DroneCAN code generation, interface and utilities

UAVCAN v0 stack in Python Python implementation of the UAVCAN v0 protocol stack. UAVCAN is a lightweight protocol designed for reliable communication

DroneCAN 11 Dec 12, 2022
Hospitality app for ERPNext to manage hotels & restaurants.

Hospitality ERPNext Hospitality module is designed to handle workflows for Hotels and Restaurants. Manage Restaurants The Restaurant module in ERPNext

Frappe 19 Dec 26, 2022
Beacon Object File (BOF) to obtain a usable TGT for the current user.

Beacon Object File (BOF) to obtain a usable TGT for the current user.

Connor McGarr 109 Dec 25, 2022
A simple script written using symbolic python that takes as input a desired metric and automatically calculates and outputs the Christoffel Pseudo-Tensor, Riemann Curvature Tensor, Ricci Tensor, Scalar Curvature and the Kretschmann Scalar

A simple script written using symbolic python that takes as input a desired metric and automatically calculates and outputs the Christoffel Pseudo-Tensor, Riemann Curvature Tensor, Ricci Tensor, Scal

2 Nov 27, 2021
The Blinker Herald includes helpers to easily emit signals using the excellent blinker library.

Blinker Herald The Blinker Herald includes helpers to easily emit signals using the excelent blinker library. Decorate a function or method with @blin

SatelliteQE 7 Nov 03, 2022