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

Hourly FFMC #4153

Merged
merged 13 commits into from
Dec 5, 2024
Merged

Hourly FFMC #4153

merged 13 commits into from
Dec 5, 2024

Conversation

dgboss
Copy link
Collaborator

@dgboss dgboss commented Dec 3, 2024

To test locally, set MAX_MODEL_RUN_HOUR to 12 or so in rdps_sfms.py and run/debug the sfms raster processor job option. You might want to delete sfms/calculated/hourlies from dev S3 storage as well to confirm the new hFFMC rasters are being generated.

Fixed: There is a known bug with warping rH rasters where it is possible to have rH values greater than 100. This breaks hFFMC calculations because the underlying cffdrs ffmc calculation has a range check on rH values to make sure they are between 0 and 100. I'll address this issue in another PR.

Calculate and store hourly FFMC rasters.

The general process is:

  1. cron job kicks off the job and we use current UTC time as start time
  2. Create HourlyFFMCProcessor with the start time and begin processing
  3. Use job start time to determine most recent RDPS model run start time (date and 00z or 12z)
  4. Use most recent RDPS model run start time to determine most recent hFFMC key to use as source which is always one hour before the RDPS start time (04 or 16 PDT)
  5. Start calculating hFFMC from model run hour 0 through to 47. Save the calculated hFFMCs to S3. Most recently calculated hFFMC is used as input to the next hour's hFFMC calculation.
  6. hFFMC rasters are saved to S3 with PDT based keys.

closes #3517

Test Links:

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

@dgboss dgboss requested review from brettedw and conbrad December 4, 2024 00:02
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 90.74074% with 10 lines in your changes missing coverage. Please review.

Project coverage is 80.73%. Comparing base (0ee473d) to head (972be14).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
api/app/jobs/sfms_calculations.py 44.44% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4153      +/-   ##
==========================================
+ Coverage   80.34%   80.73%   +0.39%     
==========================================
  Files         313      314       +1     
  Lines       11941    12040      +99     
  Branches      540      540              
==========================================
+ Hits         9594     9721     +127     
+ Misses       2159     2131      -28     
  Partials      188      188              

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

api/app/sfms/fwi_processor.py Show resolved Hide resolved
api/app/sfms/hourly_ffmc_processor.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@brettedw brettedw left a comment

Choose a reason for hiding this comment

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

Looks great, nice work!

Copy link
Collaborator

@conbrad conbrad left a comment

Choose a reason for hiding this comment

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

Nice work!

@@ -105,7 +106,7 @@ async def process(
)

# Create and store FFMC dataset
ffmc_values, ffmc_no_data_value = calculate_ffmc(ffmc_ds, warped_temp_ds, warped_rh_ds, warped_wind_speed_ds, warped_precip_ds)
ffmc_values, ffmc_no_data_value = calculate_ffmc(ffmc_ds, warped_temp_ds, warped_rh_ds, warped_precip_ds, warped_wind_speed_ds)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ouch, good find, I wonder if there's a test we could add to catch this.

Copy link
Collaborator Author

@dgboss dgboss Dec 4, 2024

Choose a reason for hiding this comment

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

We could add some sort of name or id property to WPSDataset objects and use this to assert that we're getting parameters in the right order?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I think that'd be worth it since we're passing so many WPSDataset's around

api/app/sfms/hourly_ffmc_processor.py Outdated Show resolved Hide resolved
# 3. Use job start time to determine most recent RDPS model run start time (date and 00z or 12z)
# 4. Use most recent RDPS model run start time to determine most recent hFFMC key to use as source which is always one hour before the RDPS start time (04 or 16 PDT)
# 5. Start calculating hFFMC from model run hour 0 through to 47. Save the calculated hFFMCs to S3. Most recently calculated hFFMC is used as input to the next hour's hFFMC calculation.
# 6. hFFMC rasters are saved to S3 with PDT based keys.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we using PDT for all our other S3 keys? Is there anything preventing/hindering us from using UTC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The hourly SFMS rasters we receive are named with PDT times so I followed the existing pattern. I'm totally open to naming via UTC timestamp instead. My brain definitely prefers to work in UTC as it never changes.

Copy link
Collaborator Author

@dgboss dgboss Dec 4, 2024

Choose a reason for hiding this comment

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

Oh, and our other calculated SFMS S3 rasters/keys are daily in nature, so need to consider UTC vs PDT in the naming convention.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right SFMS gives us PDT rasters. Either way works but I think adding the timezone to the naming convention would be helpful.

api/app/sfms/hourly_ffmc_processor.py Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Dec 5, 2024

@dgboss dgboss temporarily deployed to production December 5, 2024 18:13 Inactive
@dgboss dgboss merged commit a8fb048 into main Dec 5, 2024
26 checks passed
@dgboss dgboss deleted the task/hffmc/3517 branch December 5, 2024 18:22
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.

SFMS: Hourly FFMC
3 participants