Skip to content

Commit

Permalink
Merge pull request #19 from wpreimes/develop
Browse files Browse the repository at this point in the history
Update for SPL3SMP v6 and fix CI issues
  • Loading branch information
wpreimes committed Jan 16, 2020
2 parents b998e67 + f6e8713 commit 0183225
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 108 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -39,3 +39,6 @@ docs/api/*
docs/_build/*
cover/*
MANIFEST

#others
local_scripts/*
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,8 +11,8 @@ notifications:
python:
# We don't actually use the Travis Python, but this keeps it organized.
- "2.7"
- "3.6"
- "3.7"
- "3.8"
install:
# You may want to periodically update this, although the conda update
# conda line below will keep everything up-to-date. We do this
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS.rst
Expand Up @@ -2,5 +2,5 @@
Developers
==========

* Christoph Paulik <christoph.paulik@geo.tuwien.ac.at>
* Christoph Paulik <cpaulik@vandersat.com>
* Wolfgang Preimesberger <wolfgang.preimesberger@geo.tuwien.ac.at>
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,12 @@ Version 0.x
===========
-

Version 0.4
===========
- Add support for SMAP L3 v6 data,
- Remove download support for v4 and v5 (decommissioned), reading still possible.
- Add option to rename variables with orbit indicator during reading.

Version 0.3
===========

Expand Down
9 changes: 6 additions & 3 deletions README.rst
Expand Up @@ -42,19 +42,19 @@ commands:

.. code-block:: shell
conda create -q -n smap_io -c conda-forge numpy h5py pyproj netcdf4==1.2.2 pyresample scipy pandas matplotlib
conda create -q -n smap_io -c conda-forge numpy h5py pyproj netcdf4 pyresample pandas
source activate smap_io
pip install smap_io
You can also install all needed (conda and pip) dependencies at once using the
following commands after cloning this repository. This is recommended for
following commands after cloning this repository. This is recommended for
developers of the package.

.. code-block:: shell
git clone https://github.com/TUW-GEO/smap_io.git --recursive
cd smap_io
conda create -n smap_io python=2.7 # or any supported python version
conda create -n smap_io python=3.6 # or any supported python version
source activate smap_io
conda update -f environment.yml
python setup.py develop
Expand All @@ -64,6 +64,9 @@ Supported Products

- `SPL3SMP <http://nsidc.org/data/SPL3SMP>`_: SMAP L3 Radiometer Global Daily 36 km EASE-Grid Soil Moisture

Additional products will we added when need arises, feel free to open an issue to
add a new data product or even better a pull request.

Contribute
==========

Expand Down
21 changes: 0 additions & 21 deletions docs/environment.yml

This file was deleted.

9 changes: 6 additions & 3 deletions docs/read_img.rst
Expand Up @@ -11,9 +11,11 @@ data for the descending overpass of a certain date use the following code:
.. code-block:: python
from smap_io import SPL3SMP_Ds
from datetime import datetime
import os
root_path = os.path.join(os.path.dirname(__file__),
'test_data', 'SPL3SMP')
ds = SPL3SMP_Ds(root_path, overpass='AM')
ds = SPL3SMP_Ds(root_path, overpass=None, var_overpass_str=False)
image = ds.read(datetime(2015, 4, 1))
assert list(image.data.keys()) == ['soil_moisture']
assert image.data['soil_moisture'].shape == (406, 964)
Expand All @@ -27,10 +29,11 @@ If you only have a single image you can also read the data directly
.. code-block:: python
from smap_io import SPL3SMP_Img
import os
fname = os.path.join(os.path.dirname(__file__),
'test_data', 'SPL3SMP', '2015.04.01',
'SMAP_L3_SM_P_20150401_R13080_001.h5')
ds = SPL3SMP_Img(fname, overpass='PM')
ds = SPL3SMP_Img(fname, overpass=None, var_overpass_str=False)
image = ds.read()
assert list(image.data.keys()) == ['soil_moisture']
assert image.data['soil_moisture_pm'].shape == (406, 964)
assert image.data['soil_moisture'].shape == (406, 964)
4 changes: 3 additions & 1 deletion environment.yml
Expand Up @@ -8,6 +8,7 @@ dependencies:
- pyproj
- pandas
- pyresample
- pip
- pip:
- datedown
- ease-grid
Expand All @@ -16,5 +17,6 @@ dependencies:
- pytesmo
- repurpose
- trollsift==0.2.1
- pynetcf==0.1.18
- pynetcf
- more_itertools
- parse
3 changes: 2 additions & 1 deletion requirements.txt
Expand Up @@ -8,5 +8,6 @@ ease_grid
repurpose
trollsift==0.2.1
datedown
pynetcf==0.1.18
pynetcf
more_itertools
parse
37 changes: 11 additions & 26 deletions smap_io/download.py
Expand Up @@ -304,8 +304,7 @@ def get_first_formatted_dir_in_dir(folder, fmt):


def get_start_date(product):
dt_dict = {'SPL3SMP.004': datetime(2015, 3, 31, 0),
'SPL3SMP.005': datetime(2015, 3, 31, 0)}
dt_dict = {'SPL3SMP.006': datetime(2015, 3, 31, 0)}
return dt_dict[product]


Expand All @@ -322,15 +321,15 @@ def parse_args(args):
help='Root of local filesystem where the data is stored.')
parser.add_argument("-s", "--start", type=mkdate,
help=("Startdate. Either in format YYYY-MM-DD or YYYY-MM-DDTHH:MM."
"If not given then the target folder is scanned for a start date."
"If no data is found there then the first available date of the product is used."))
" If not given then the target folder is scanned for a start date."
" If no data is found there then the first available date of the product is used."))
parser.add_argument("-e", "--end", type=mkdate,
help=("Enddate. Either in format YYYY-MM-DD or YYYY-MM-DDTHH:MM."
"If not given then the current date is used."))
parser.add_argument("--product", choices=["SPL3SMP.004", "SPL3SMP.005"],
default="SPL3SMP.005",
help='SMAP product to download. (default: SPL3SMP.005).'
'See also https://nsidc.org/data/smap/data_versions#L3 ')
" If not given then the current date is used."))
parser.add_argument("--product", choices=["SPL3SMP.006"],
default="SPL3SMP.006",
help='SMAP product to download. (default: SPL3SMP.006).'
' See also https://nsidc.org/data/smap/data_versions#L3 ')
parser.add_argument("--username",
help='Username to use for download.')
parser.add_argument("--password",
Expand All @@ -350,12 +349,9 @@ def parse_args(args):
if args.end is None:
args.end = datetime.now()

prod_urls = {'SPL3SMP.004':
{'root': 'https://n5eil01u.ecs.nsidc.org',
'dirs': ['SMAP', 'SPL3SMP.004', '%Y.%m.%d']},
'SPL3SMP.005':
{'root': 'https://n5eil01u.ecs.nsidc.org',
'dirs': ['SMAP', 'SPL3SMP.005', '%Y.%m.%d']},
prod_urls = {'SPL3SMP.006':
{'root': 'https://n5eil01u.ecs.nsidc.org',
'dirs': ['SMAP', 'SPL3SMP.006', '%Y.%m.%d']},
}

args.urlroot = prod_urls[args.product]['root']
Expand All @@ -374,7 +370,6 @@ def main(args):

args = parse_args(args)

#args.urlsubdirs = args.urlsubdirs[:2]
dts = list(daily(args.start, args.end))
i = 0
while(len(dts) != 0) and i < 3: # after 3 reties abort
Expand Down Expand Up @@ -406,13 +401,3 @@ def main(args):
def run():
main(sys.argv[1:])


if __name__ == '__main__':
cmd = ['path_to_images',
'-s', '2016-09-27', '-e', '2016-09-27',
'--product', 'SPL3SMP.005',
'--username', '******',
'--password', '****',
'--n_proc', '1']
main(cmd)

0 comments on commit 0183225

Please sign in to comment.