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
This repository containing cross-section cut and fill calculations using Python programming language.

cross-section This repository is containing cut and fill calculations for cross-section using Python programming language. This codes is made to calcu

3 Jun 15, 2022
ELF file deserializer and serializer library

elfo ELF file deserializer and serializer library. import elfo elf = elfo.ELF.from_path('main') elf ELF( header=ELFHeader( e_ident=e

Filipe Laíns 3 Aug 23, 2021
py-js: python3 objects for max

Simple (and extensible) python3 externals for MaxMSP

Shakeeb Alireza 39 Nov 20, 2022
emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

Andrew White 13 Dec 11, 2022
This bot uploads telegram files to MixDrop.co,File.io.

What is about this bot ? This bot uploads telegram files to MixDrop.co, File.io. Usage: Send any file, and the bot will upload it to MixDrop.co, File.

Abhijith NT 3 Feb 26, 2022
Projeto job insights - Projeto avaliativo da Trybe do Bloco 32: Introdução à Python

Termos e acordos Ao iniciar este projeto, você concorda com as diretrizes do Código de Ética e Conduta e do Manual da Pessoa Estudante da Trybe. Boas

Lucas Muffato 1 Dec 09, 2021
Pacman - A suite of tools for manipulating debian packages

Overview Repository is a suite of tools for manipulating debian packages. At a h

Pardis Pashakhanloo 1 Feb 24, 2022
Headless chatbot that detects spam and posts links to it to chatrooms for quick deletion.

SmokeDetector Headless chatbot that detects spam and posts it to chatrooms. Uses ChatExchange, takes questions from the Stack Exchange realtime tab, a

Charcoal 421 Dec 21, 2022
Find out where all films you want to watch are streaming

Just Watch Letterboxd Find out where all films you want to watch are streaming Ever wonder what films you want to watch are already on the streaming p

Jordan Oslislo 2 Feb 04, 2022
A napari plugin to inspect data within a cisTEM project

napari-cistem A plugin to inspect data within a cisTEM project This napari plugin was generated with Cookiecutter using with @napari's cookiecutter-na

Johannes Elferich 1 Nov 07, 2021
En este repositorio realizaré la tarea del laberinto.

Laberinto Perfil de GitHub del autor de este proyecto: @jmedina28 En este repositorio queda resuelta la composición de un laberinto 5x5 con sus muros

Juan Medina 1 Dec 11, 2021
Open source style Deep Dream project

DeepDream ⚠️ If you don't have a gpu with cuda, the style transfer execution time will be much longer Prerequisites Python =3.8.10 How to Install sud

Patrick martins de lima 7 May 17, 2022
Project for viewing the cheapest flight deals from Netherlands to other countries.

Flight_Deals_AMS Project for viewing the cheapest flight deals from Netherlands to other countries.

2 Dec 17, 2022
Write complicated anonymous functions other than lambdas in Python.

lambdex allows you to write multi-line anonymous function expression (called a lambdex) in an idiomatic manner.

Xie Jingyi 71 May 19, 2022
Estimate the Market Size for Electic and Plug-In Hybrid Vehicles In Africa

Estimate the Market Size for Electic and Plug-In Hybrid Vehicles In Africa The goal of this repository is to use open data repositories to answer the

Leonce Nshuti 0 Feb 21, 2022
A code base for python programs the goal is to integrate all the useful and essential functions

Base Dev EN This GitHub will be available in French and English FR Ce GitHub sera disponible en français et en anglais Author License Screen EN 🇬🇧 D

Pikatsuto 1 Mar 07, 2022
Launcher program to select which version of the Q-Sys software to launch.

QSC-QSYS Launcher Launcher program to select which version of the Q-Sys software to launch. Instructions To use the application simply save the "Q-Sys

Zach Lisko 2 Sep 28, 2022
Check bookings for TUM libraries.

TUM Library Checker Only for educational purposes This repository contains a crawler to save bookings for TUM libraries in a CSV file. Sample data fro

Leon Blumenthal 3 Jan 27, 2022
Automates the fixing of problems reported by yamllint by parsing its output

yamlfixer yamlfixer automates the fixing of problems reported by yamllint by parsing its output. Usage This software automatically fixes some errors a

OPT Nouvelle Caledonie 26 Dec 26, 2022
4Geeks Academy Full-Stack Developer program final project.

Final Project Chavi, Clara y Pablo 4Geeks Academy Full-Stack Developer program final project. Authors Javier Manteca - Coding - chavisam Clara Rojano

1 Feb 05, 2022