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
Our Ping Pong Project of numerical analysis, 2nd year IC B2 INSA Toulouse

Ping Pong Project The objective of this project was to determine the moment of impact of the ball with the ground. To do this, we used different model

0 Jan 02, 2022
An open source server for Super Mario Bros. 35

SMB35 A custom server for Super Mario Bros. 35 This server is highly experimental. Do not expect it to work without flaws.

Yannik Marchand 162 Dec 07, 2022
Bu repoda python ile CAN-Bus çalışmalarını nasıl gerçekleyeceğiniz anlatılmaktadır.

CAN-Bus-with-Python "CAN Bus 1980'li yıllarda Robert BOSCH tarafından geliştirilmiş bir iletişim protokoldür. Hızlı ve hata oranının çok düşük olması

Yunus Emre Coşkun 16 Aug 29, 2022
A Python wrapper for Matrix Synapse admin API

Synapse-admin-api-python A Python wrapper for Matrix Synapse admin API. Versioning This library now supports up to Synapse 1.45.0, any Admin API intro

Knugi 9 Sep 28, 2022
Tracing and Observability with OpenFaaS

Tracing and Observability with OpenFaaS Today we will walk through how to add OpenTracing or OpenTelemetry with Grafana's Tempo. For this walk-through

Lucas Roesler 8 Nov 17, 2022
Imports an object based on a string import_string('package.module:function_name')() - Based on werkzeug.utils

DEPRECATED don't use it. Please do: import importlib foopath = 'src.apis.foo.Foo' module_name = '.'.join(foopath.split('.')[:-1]) # to get src.apis.f

Bruno Rocha Archived Projects 11 Nov 12, 2022
Calc.py - A powerful Python REPL calculator

Calc - A powerful Python REPL calculator This is a calculator with a complex sou

Alejandro 8 Oct 22, 2022
A simple desktop application to scan and export Genshin Impact Artifacts.

「天目」 -- Amenoma 简体中文 | English 「天目流的诀窍就是滴水穿石的耐心和全力以赴的意志」 扫描背包中的圣遗物,并导出至 json 格式。之后可导入圣遗物分析工具( 莫娜占卜铺 、 MingyuLab 、 Genshin Optimizer 进行计算与规划等。 已支持 原神2.

夏至 475 Dec 30, 2022
A prototype COG-based tile server for sparse Mars datasets

Mars tiler Mars Tiler is a prototype web application that serves tiles from cloud-optimized GeoTIFFs, with an emphasis on supporting planetary dataset

Daven Quinn 3 Mar 23, 2022
Code emulator plugin for IDA Pro

emu_ida Code emulator plugin for IDA Pro (v 0.0.6) The plugin is designed for simple data decryption and getting stack strings. Requirements Emulator

Andrey Zhdanov 11 Jul 06, 2022
Fork of pathlib aiming to support the full stdlib Python API.

pathlib2 Fork of pathlib aiming to support the full stdlib Python API. The old pathlib module on bitbucket is in bugfix-only mode. The goal of pathlib

Jazzband 73 Dec 23, 2022
Simple python bot, that notifies about new manga chapters through Telegram.

Simple python bot, that notifies about new manga chapters through Telegram.

Dmitry Kopturov 1 Dec 05, 2021
Node editor view image node

A Blender addon to quickly view images from image nodes in Blender's image viewer.

5 Nov 27, 2022
A program to calculate the are of a triangle. made with Python.

Area-Calculator What is Area-Calculator? Area-Calculator is a program to find out the area of a triangle easily. fully made with Python. Needed a pyth

Chandula Janith 0 Nov 27, 2021
Double Pendulum implementation in Python, now with added pendulums and trails :D

Double Pendulum Using Curses in Python. A nice relaxing double pendulum simulation using ASCII, able to simulate multiple pendulums at once, and provi

Nekurone 62 Dec 14, 2022
Free Vocabulary Trainer - not only for German, but any language

Bilderraten DOWNLOAD THE EXE FILE HERE! What can you do with it? Vocabulary Trainer for any language Use your own vocabulary list No coding required!

Hans Alemão 4 Jan 02, 2023
Myrepo - A tool to create your own Arch Linux repository

myrepo A (experimental) tool to create your own Arch Linux repository Example We

Anton Hvornum 5 Feb 19, 2022
Graveyard is an attempt at open-source reimplementation of DraciDoupe.cz

Graveyard: Place for Dead (and Undead) Graveyard is an attempt at open-source reimplementation of DraciDoupe.cz (referred to as DDCZ in this text). De

DraciDoupe.cz 5 Mar 17, 2022
A webdav demo using a virtual filesystem that serves a random status of whether a cat in a box is dead or alive.

A webdav demo using a virtual filesystem that serves a random status of whether a cat in a box is dead or alive.

Marshall Conover 2 Jan 12, 2022
A redesign of our previous Python World Cup, aiming to simulate the 2022 World Cup all the way from the qualifiers

A redesign of our previous Python World Cup, aiming to simulate the 2022 World Cup all the way from the qualifiers. This new version is designed to be more compact and more efficient and will reflect

Sam Counsell 1 Jan 07, 2022