Giter Club home page Giter Club logo

cygnss-wetlands's Introduction

cygnss-wetlands

A repo dedicated to investigating global inundation patterns with NASA CYGNSS observations and other supporting data sources.


Installation

This project's dependencies are managed with Poetry. Learm more about its basic usage

1. Clone Repo

git clone [email protected]:katjensen/cygnss-wetlands.git

2. Install Poetry (if not already installed on system)

curl -sSL https://install.python-poetry.org | python3 -

3. Set up Python environmentment

Two options here:

(a) Create and activate a fresh, new python environment using your Python environment manager of choice (e.g conda). This project requires Python version 3.9 or greater.

conda create -n cygnss-wetlands python=3.9
conda activate cygnss-wetlands

or

(b) Instruct Poetry to use an existing conda (or pyenv, etc) python version as it's base. A new virtual env will be created and managed by Poetry directly. You'll need to point it at the python executable. For example:

poetry env use /opt/homebrew/Caskroom/miniconda/base/envs/base-python-3.9/bin/python3

If you are not using conda, you might want to enable the virtualenvs.in-project option for this project (optional) by running in the project root directory:

 poetry config virtualenvs.in-project true

This will cause Poetry to create new environments in $project_root/.venv/. If you rename the project directory the environment should continue to work.

4. Install package

You can install project dependencies, along with pre-commit git hooks, by:

make install

5. Activate your environment

If you are NOT using conda to manage your environment, when working on this project (now and in the future), activate your environment by:

poetry shell

This command creates a child process that inherits from the parent Shell but will not alter its environment. It encapsulates and restrict any modifications you will perform to your project environment.

If you want, you may install this cygnss-wetlands library in editable mode once dependencies have been installed (and your environment is activated) by:

pip install -e .

6. Some additional tips about Poetry

To add a package to your project using poetry CLI,

poetry add "[your_package]"

You can also manually update pyproject.toml to include a new dependency (or change Python verions or existing dependency versions) manually. This will require you to recreate the poetry.lock file in the project, which you can do by following the command below.

poetry update

Credentials and Environment Variables

If using the download tool, you will need NASA Earthdata account credentials either stored in a .env file in this project's root folder or added to your local environment:

EARTHDATA_USERNAME=XXXXXXX
EARTHDATA_PASSWORD=XXXXXXX

CLI Tools

Download CYGNSS data

A little command line tool can help you download files from PODAAC HTTP site. Only currently supports L1 products. TODO: Upgrade the downloader to pull from S3 bucket -- at the time of development, this was only accessible in AWS region aws-west-2

For example, to download one month's worth of L1 files from Jan 2020, you can run :

cygnss download --product_level=L1 --start_date=2020-01-01 --end_date=2020-01-31 --dest_dir=/path/to/cygnss/data

Aggregating L1 to Grid

Not Implemented: Aggregating CYGNSS L1 data to a regular grid and write to file


Remaining To-Do List

There are components of previous work that are still being added here - plus some valuable upgrades - in the works!

  1. Logging and unit testing
  2. Custom DDM observables derived from BRCS (e.g. leading and trailing edge slope)
  3. Upgrade Download tool to pull from HTTP site to AWS S3 and Reader infrastructure to read from the cloud (switch to using xarray !) - this would help us not have to download all data files locally (but last I checked-- this was still only available to users in aws-west-2 region)
  4. Add support for additional grid types (e.g. UTM, Geographic Coordinates) - currently only support EASEGRIDs
  5. Add CLI support to aggregate() for writing out to file
  6. Sentinel-1 and PALSAR-2 support -- needs scoping !

cygnss-wetlands's People

Contributors

katjensen avatar sberndtjpl avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

cygnss-wetlands's Issues

File Fragments Lead to Unreadable Data

Description
File fragments lead to unreadable data

I found that when utilizing the downloader via commands such as cygnss download --product_level=L1 --start_date=2020-04-18 --end_date=2020-04-18 --dest_dir=/Volumes/Apricorn/cygnss_data occasionally I would receive file sizes that are ~95kb. See SS below. This would happen for long stretches (Almost all of 2021)

To Reproduce
So far unable to reproduce.

Steps to reproduce the behavior:

  1. Setup environment
  2. Run script cygnss download --product_level=L1 --start_date=2020-04-01 --end_date=2020-06-30 --dest_dir=/Volumes/Apricorn/cygnss_data
  3. Wait...

Expected behavior
A clear and concise description of what you expected to happen.
Do not accept downloads that are not valid & delete invalid downloads when rerunning the download script

Screenshots
If applicable, add screenshots to help explain your problem.
image

Additional context
Add any other context about the problem here.
This may be related to errors such as Could not download file: cyg02.ddmi.s20200414-000000-e20200414-235959.l1.power-brcs.a31.d32.nc, error: HTTP Error 404: Not Found

HTTP404 Error when Downloading CYGNSS Data

Description
Receive an HTTP 404 error when attempting to download file utilizing this command cygnss download --product_level=L1 --start_date=2020-01-01 --end_date=2020-01-31 --dest_dir=/path/to/cygnss/data

Specifically happens for cyg04.ddmi.s20200130-000000-e20200130-235959.l1.power-brcs.a31.d32.nc

To Reproduce
Steps to reproduce the behavior:

  1. In your terminal, enter the following command with your respective destination directory cygnss download --product_level=L1 --start_date=2020-01-30 --end_date=2020-01-30 --dest_dir=/path/to/data
  2. Wait for the download of the first 3 spacecrafts to complete
  3. Notice HTTP 404 Error terminates program, seen below.

Expected behavior
If file does not exist, handle exception.

Screenshots
N/A, See error text below

Additional context
The command cygnss download --product_level=L1 --start_date=2020-01-01 --end_date=2020-01-31 --dest_dir=/path/to/cygnss/data is referenced in the README

Automated Testing

  • An automated test has been created to check for this bug in the future

Error Text

  File "/Users/sberndt/anaconda3/bin/cygnss", line 8, in <module>
    sys.exit(entry())
             ^^^^^^^
  File "/Users/sberndt/Documents/cygnss-wetlands/cygnss_wetlands/cygnss/cli.py", line 116, in entry
    main(obj={})
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/Documents/cygnss-wetlands/cygnss_wetlands/cygnss/cli.py", line 109, in download
    filelist = http_download_by_date(product_level, date, dest_subdir, overwrite)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/Documents/cygnss-wetlands/cygnss_wetlands/cygnss/download.py", line 108, in http_download_by_date
    with urllib.request.urlopen(request) as response, open(complete_filepath, "wb") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 1056, in http_error_401
    response = self.http_error_auth_reqed('www-authenticate',
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 1005, in http_error_auth_reqed
    return self.retry_http_basic_auth(host, req, realm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 1020, in retry_http_basic_auth
    return self.parent.open(req, timeout=req.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/sberndt/anaconda3/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found```

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.