Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic for processing VIIRS snow data #3332

Merged
merged 14 commits into from
Jan 25, 2024
Merged

Logic for processing VIIRS snow data #3332

merged 14 commits into from
Jan 25, 2024

Conversation

dgboss
Copy link
Collaborator

@dgboss dgboss commented Jan 19, 2024

The general flow is:

  1. Check the api database for the date of the last successful processing of VIIRS snow data.
  2. Download bc_boundary.geojson from S3 into a temp directory
  3. Download 'granules' (tif files representing satellite passes over BC) into another temp directory
  4. Create a single image (aka mosaic) from the downloaded tifs
  5. Clip the single image using the bc_boundary.geojson file
  6. Upload the clipped file to S3 storage

Occasionally there is a delay in availability of the data. If we encounter this we exit gracefully and try again the next time the cron job runs. This is a pretty specific HTTP status code (501). All other errors get logged and a notification sent to RocketChat.

You can view the output files in S3 at /snow_coverage/{YYYY-mm-dd}/*.tif. The most recent folder should ideally correspond with the most recent available folder at https://n5eil01u.ecs.nsidc.org/VIIRS/VJ110A1.002/.

Test Links:

Landing Page
MoreCast 2.0
Percentile Calculator
MoreCast
C-Haines
FireBat
FireBat bookmark
Auto Spatial Advisory (ASA)
HFI Calculator

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (9bb7487) 81.53% compared to head (7a46ae7) 81.39%.

Files Patch % Lines
api/app/jobs/viirs_snow.py 61.46% 42 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3332      +/-   ##
==========================================
- Coverage   81.53%   81.39%   -0.15%     
==========================================
  Files         277      278       +1     
  Lines        9560     9681     +121     
  Branches      450      450              
==========================================
+ Hits         7795     7880      +85     
- Misses       1646     1682      +36     
  Partials      119      119              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dgboss dgboss closed this Jan 22, 2024
@dgboss dgboss reopened this Jan 22, 2024
@dgboss dgboss requested review from conbrad and brettedw January 23, 2024 00:44
@@ -184,7 +184,7 @@ class ModelRunPrediction(Base):
# The date and time to which the prediction applies.
prediction_timestamp = Column(TZTimeStamp, nullable=False, index=True)
# The station code representing the location (aka weather station).
station_code = Column(Integer, nullable=True)
station_code = Column(Integer, nullable=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this should have always been False, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I think I originally had it set to True as a column was being added to an existing table so there was the possibility of null values and providing a default didn't make sense. In the end I deleted the contents of the table in the migration and had the migration set nullable=False. This change brings the code into alignment with the current schema of the db.

session = requests.session()
resp = session.get(f"https://n5eil02u.ecs.nsidc.org/egi/capabilities/{SHORT_NAME}.{PRODUCT_VERSION}.xml")
session.get(resp.url, auth=(config.get("NASA_EARTHDATA_USER"),config.get("NASA_EARTHDATA_PWD")))
# Check if request was successful
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we do 2 requests here? One to authenticate, then one to get the data. Where are we checking that the auth request was successful?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that's a leftover comment at this spot that I'll remove. The check to see if we've made a successful request actually occurs below with request.raise_for_status(). If the request for data returns anything but a 200 this call with raise an error which we subsequently handle.

api/app/jobs/viirs_snow.py Outdated Show resolved Hide resolved
api/app/jobs/viirs_snow.py Outdated Show resolved Hide resolved
dgboss and others added 2 commits January 23, 2024 09:32
Co-authored-by: Conor Brady <con.brad@gmail.com>
Co-authored-by: Conor Brady <con.brad@gmail.com>
api/app/jobs/viirs_snow.py Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jan 24, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@dgboss dgboss temporarily deployed to production January 24, 2024 19:54 Inactive
@dgboss dgboss merged commit d0e2874 into main Jan 25, 2024
30 checks passed
@dgboss dgboss deleted the task/process-snow/3254 branch January 25, 2024 18:08
vanislekahuna pushed a commit to vanislekahuna/wps that referenced this pull request Sep 19, 2024
Co-authored-by: Conor Brady <con.brad@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants