Giter VIP home page Giter VIP logo

fierpy's Introduction

fierpy

Python: 3.8 License: MIT SERVIR: Global

Python implementation of the Forecasting Inundation Extents using REOF method

Based off of the methods from Chang et al., 2020

Installation

$ conda create -n fier -c conda-forge python=3.8 netcdf4 qt pyqt rioxarray numpy scipy xarray pandas scikit-learn eofs geoglows

$ conda activate fier

$ pip install git+https://github.com/servir/fierpy.git

To Install in OpenSARlab:

$ conda create --prefix /home/jovyan/.local/envs/fier python=3.8 netcdf4 qt pyqt rioxarray numpy scipy xarray pandas scikit-learn eofs geoglows jupyter kernda

$ conda activate fier

$ pip install git+https://github.com/servir/fierpy.git

$ /home/jovyan/.local/envs/fier/bin/python -m ipykernel install --user --name fier

$ conda run -n fier kernda /home/jovyan/.local/share/jupyter/kernels/fier/kernel.json --env-dir /home/jovyan/.local/envs/fier -o

Requirements

  • numpy
  • xarray
  • pandas
  • eofs
  • geoglows
  • scikit-learn
  • rasterio

Example use

import xarray as xr
import fierpy

# read sentinel1 time series imagery
ds = xr.open_dataset("sentine1.nc")

# apply rotated eof process
reof_ds = fierpy.reof(ds.VV,n_modes=4)

# get streamflow data from GeoGLOWS
# select the days we have observations
lat,lon = 11.7122,104.9653
q = fierpy.get_streamflow(lat,lon)
q_sel = fierpy.match_dates(q,ds.time)

# apply polynomial to different modes to find best stats
fit_test = fierpy.find_fits(reof_ds,q_sel,ds)

License and Distribution

fierpy is distributed by SERVIR under the terms of the MIT License. See LICENSE in this directory for more information.

Privacy & Terms of Use

fierpy abides to all of SERVIR's privacy and terms of use as described at https://servirglobal.net/Privacy-Terms-of-Use.

fierpy's People

Contributors

kmarkert avatar alex-lewandowski avatar billyz313 avatar chchang1990 avatar skd862 avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar R. Sahajpal avatar SERVIR avatar Lance avatar  avatar

fierpy's Issues

Null Values in Streamflow

Any null values in streamflow cause the regression fitting to fail. It would be useful to have something that filters null values when matching dates.

Include unit tests

We should include unit tests within the package to verify that the functions are producing the expected results and any PRs are not breaking functionality.

Include CLI for executing operationally executing workflow

Currently FIERpy is setup to run as an interactive process which is good for exploring but is not conductive for replicability across different envs and ops.

We can replicate the CLI off of other Python-based scientific processing packages like RVICand MetSim. They have an internal API which the CLI calls and allows users to hack if needed.

REOF function fails


TypeError Traceback (most recent call last)
/var/folders/z4/1gpfvpc91k58ljkw_dt89vgr0000gr/T/ipykernel_2342/4137204616.py in
1 # apply rotated eof process
----> 2 reof_ds = fierpy.reof(ds.VV,n_modes=4)

~/opt/miniconda3/envs/fier/lib/python3.8/site-packages/fierpy/fier.py in reof(stack, variance_threshold, n_modes)
82
83 # structure the spatial and temporal reof components in a Dataset
---> 84 reof_ds = xr.Dataset(
85 {
86 "spatial_modes": (["lat","lon","mode"],spatial_rotated),

~/opt/miniconda3/envs/fier/lib/python3.8/site-packages/xarray/core/dataset.py in init(self, data_vars, coords, attrs)
752 coords = coords.variables
753
--> 754 variables, coord_names, dims, indexes, _ = merge_data_and_coords(
755 data_vars, coords, compat="broadcast_equals"
756 )

~/opt/miniconda3/envs/fier/lib/python3.8/site-packages/xarray/core/merge.py in merge_data_and_coords(data, coords, compat, join)
481 objects = [data, coords]
482 explicit_coords = coords.keys()
--> 483 indexes = dict(_extract_indexes_from_coords(coords))
484 return merge_core(
485 objects, compat, join, explicit_coords=explicit_coords, indexes=indexes

~/opt/miniconda3/envs/fier/lib/python3.8/site-packages/xarray/core/merge.py in _extract_indexes_from_coords(coords)
490 """Yields the name & index of valid indexes from a mapping of coords"""
491 for name, variable in coords.items():
--> 492 variable = as_variable(variable, name=name)
493 if variable.dims == (name,):
494 yield name, variable._to_xindex()

~/opt/miniconda3/envs/fier/lib/python3.8/site-packages/xarray/core/variable.py in as_variable(obj, name)
119 elif isinstance(obj, tuple):
120 if isinstance(obj[1], DataArray):
--> 121 raise TypeError(
122 "Using a DataArray object to construct a variable is"
123 " ambiguous, please extract the data using the .data property."

TypeError: Using a DataArray object to construct a variable is ambiguous, please extract the data using the .data property.

Here is the version information:

INSTALLED VERSIONS
------------------
commit: None
python: 3.8.12 | packaged by conda-forge | (default, Sep 29 2021, 19:44:33) 
[Clang 11.1.0 ]
python-bits: 64
OS: Darwin
OS-release: 20.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.1
libnetcdf: 4.8.1

xarray: 0.19.0
pandas: 1.3.3
numpy: 1.21.2
scipy: 1.7.1
netCDF4: 1.5.7
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.5.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.2.10
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.4.3
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 58.2.0
pip: 21.3
conda: None
pytest: None
IPython: 7.28.0
sphinx: None

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.