semvec/pypi-packages huggingface dataset:
pymt-nwm 0.1
PyMT plugin for pymt_nwm
Keywords: bmi,pymt

==============
pymt_nwm
==============


.. image:: https://img.shields.io/badge/CSDMS-Basic%20Model%20Interface-green.svg
        :target: https://bmi.readthedocs.io/
        :alt: Basic Model Interface

.. .. image:: https://img.shields.io/badge/recipe-pymt_nwm-green.svg
        :target: https://anaconda.org/conda-forge/pymt_nwm

.. image:: https://readthedocs.org/projects/pymt-nwm/badge/?version=latest
        :target: https://pymt-nwm.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status

.. image:: https://img.shields.io/badge/License-MIT-blue.svg
        :target: hhttps://github.com/gantian127/pymt_nwm/blob/master/LICENSE


pymt_nwm is a package that converts `nwm package <https://github.com/gantian127/nwm>`_ into a reusable,
plug-and-play data component for `PyMT <https://pymt.readthedocs.io/en/latest/?badge=latest>`_ modeling framework.
This allows the National Water Model datasets to be easily coupled with other datasets or models that expose
a `Basic Model Interface <https://bmi.readthedocs.io/en/latest/>`_.

---------------
Installing pymt
---------------

Installing `pymt` from the `conda-forge` channel can be achieved by adding
`conda-forge` to your channels with:

.. code::

  conda config --add channels conda-forge

*Note*: Before installing `pymt`, you may want to create a separate environment
into which to install it. This can be done with,

.. code::

  conda create -n pymt python=3
  conda activate pymt

Once the `conda-forge` channel has been enabled, `pymt` can be installed with:

.. code::

  conda install pymt

It is possible to list all of the versions of `pymt` available on your platform with:

.. code::

  conda search pymt --channel conda-forge

-------------------------
Installing pymt_nwm
-------------------------

To install `pymt_nwm`,

.. code::

  pip install pymt_nwm



Credits
=======

* Tian Gan <gantian127@gmail.com>


Changelog for pymt_nwm
======================

0.2.0 (unreleased)
-------------------


0.1.0 (2021-03-22)
------------------

- Initial release
nwm 0.1.3
Fetch and process data from the National Water Model

# nwm
[![Documentation Status](https://readthedocs.org/projects/nwm/badge/?version=latest)](https://nwm.readthedocs.io/en/latest/?badge=latest)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gantian127/nwm/blob/master/LICENSE.txt)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/gantian127/nwm/master?filepath=notebooks%2Fnwm.ipynb)



Python library to fetch and process the National Water Model (NWM) NetCDF datasets. 

If you have any suggestion to improve the current function, please create a github issue 
[here](https://github.com/gantian127/nwm/issues).
## Get Started



#### Install package

```
$ pip install nwm
```

#### Download NWM Data
You can launch binder to test and run the code below.

##### Example 1: use NwmHs class to download data (Recommended method)

```python
import matplotlib.pyplot as plt
from nwm import NwmHs

# get data from National water model HydroShare App
nwm_data = NwmHs()
dataset = nwm_data.get_data(archive='harvey', config='short_range', geom='channel_rt', variable='streamflow',
                           comid=[5781915], init_time=0, start_date='2017-08-23')

# show metadata
dataset.attrs

# plot data
plt.figure(figsize=(9,5))
dataset.plot()
plt.xlabel('Year 2017')
plt.ylabel('{} ({})'.format(dataset.variable_name,dataset.variable_unit))
plt.title('Short range streamflow forecast for Channel 5781915 during Harvey Hurricane Event')
```
![ts_plot](docs/source/_static/ts_plot.png)

##### Example 2: use BmiNwmHs class to download data (Demonstration of how to use BMI)

```python
import matplotlib.pyplot as plt
import numpy as np
import cftime

from nwm import BmiNwmHs


# initiate a data component
data_comp = BmiNwmHs()
data_comp.initialize('config_file.yaml')

# get variable info
var_name = data_comp.get_output_var_names()[0]
var_unit = data_comp.get_var_units(var_name)
print(' variable_name: {}\n var_unit: {}\n'.format(var_name, var_unit))

# get time info
start_time = data_comp.get_start_time()
end_time = data_comp.get_end_time()
time_step = data_comp.get_time_step()
time_unit = data_comp.get_time_units()
time_steps = int((end_time - start_time)/time_step) + 1
print(' start_time:{}\n end_time:{}\n time_step:{}\n time_unit:{}\n time_steps:{}\n'.format(start_time, end_time, time_step, time_unit, time_steps))

# initiate numpy arrays to store data
stream_value = np.empty(1)
stream_array = np.empty(time_steps)
cftime_array = np.empty(time_steps)

for i in range(0, time_steps):
    data_comp.get_value(var_name, stream_value)
    stream_array[i] = stream_value
    cftime_array[i] = data_comp.get_current_time()
    data_comp.update()

time_array = cftime.num2date(cftime_array, time_unit, only_use_cftime_datetimes=False, only_use_python_datetimes=True)

# plot data
plt.figure(figsize=(9,5))
plt.plot(time_array, stream_array)
plt.xlabel('Year 2017')
plt.ylabel('{} ({})'.format(var_name, var_unit))
plt.title('Short range streamflow forecast for Channel 5781915 during Harvey Hurricane Event')
```
get-province-city-county 1.3.0
这是一个从文本提取中文地区的包
Requires Python: >=3.0

这是一个专门从文本里面提取中国的省，市，县的一个python模块
=======================================================
例子：
```python
from get_province_city_county.city import mycity
citys = mycity.get_city("我出生在一个名字叫安徽的省份，我去过浙江，江苏，合肥还有淮南，但我最喜欢的还是合肥，因为我在蜀山区生活过一段时间")
print(citys)
```
结果:[['安徽', 5, '淮南', 2, None, 0, False, [1, 1]]]

你也可以通过h_zd参数来指定要提取的省市范围，将提取范围缩小，以便得到更精确的结果

例子:
```python
from get_province_city_county.city import mycity
citys = mycity.get_city("我出生在一个名字叫安徽的省份，我去过浙江，江苏，台州，合肥还有淮南，但我最喜欢的还是合肥，因为我在蜀山区生活过一段时间",h_zd="浙江")
print(citys)
```
结果:[['浙江', 5, '台州', 2, None, 0, False, [1, 1]]]

通过h_zd这个参数，就可以锁定范围了