GithubHelp home page GithubHelp logo

density_stats's Introduction

Code for Model-Data comparisons based on distributions

This repository includes code to analyze distributions of geophysical data as described in the XXX publication. We provide the following functionaly:

  • Calculate statistics from histograms (histogram.py)
  • Create Taylor diagrams from histograms (taylor.py)
  • Calculate Earth Mover's distances from histograms (earthmover.py)
  • Generate figures for the paper (paper_figures.py)
  • Some simple example of how to generate histograms from netcdf files.

The repository also includes all necessary data as histograms used in the analysis presented in the paper. The raw data needed to generate the histograms are accessible from reposotories referenced in the paper.

The figures_in_paper contains all figures not included in the paper.

Prerequisites

The following pypi packages are necessary for the code to work:

  • xarray
  • scipy
  • numpy
  • matplotlib
  • netcdf4
  • pytables
  • h5py
  • cartopy
  • pyresample
  • projmap

Cartopy can be challenging to install. Please see the cartopy website for instructions.

Installation

The easiest way to set up all prerequisites including cartopy is via conda:

  1. Create a new conda environment
conda env create -f environment.yml
  1. Activate the environment
conda activate modeldata_GBC
  1. Start the interactive ipython shell
ipython

Usage

Thesa are some few examples of how to use the modules. The main general is to generate, perform statistics, and analysis on diferent kinds of histograms.

Calculate histograms from opendap/netcdf fields

import retrieve_cci

histmat = retrieve_cci.fields_to_histograms(date1="2001-01-01", date2="2001-12-31")
#histmat has the dimensions (months,regions,bins)

Calculate histograms for OC-CCI is very time consuming and doing it for Darwin requires specialized scripts. We provide pre-generated data in the netcdf file datafiles/cci_darwin_monthly_histograms_100bins.nc or via a method:

Load pre-calculated histograms

import histogram

ds = histogram.open_dataset()
# The dataset contains the following datavars:
#   cci         OC-CCI Chl
#   dr_chl      Darwin Chl, same as Chl_mod in the paper
#   dr_sat      Darwin Chl from Rrs, same as Chl_Rrs in the paper
#   dr_chl_mask Chl_mod masked by removing pixels invalid in OC-CCI
#   dr_sat_mask Chl_Rrs masked by removing pixels invalid in OC-CCI

Calculate statistics over histograms

import histogram

ds = histogram.open_dataset()
hs = histogram.Stats()

hs.median_(ds.cci[0,10,:]) #Median value of Chl_sat for Jan in province 10
hs.var_(ds.cci[7,22,:])  #Variance of Chl_Rrs for Aug in province 22

Earth Mover's Distances

import earthmover

em = earthmover.Hist()
em_mod_arr = em.emd_hist(darwin="mod")
em_rrs_arr = em.emd_hist(darwin="rrs")

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Bror Jonsson - [email protected]

density_stats's People

Contributors

brorfred avatar

Watchers

 avatar

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.