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

feat: plot DOY by seasons #393

Merged
merged 6 commits into from
Dec 9, 2024
Merged

feat: plot DOY by seasons #393

merged 6 commits into from
Dec 9, 2024

Conversation

12rambau
Copy link
Member

@12rambau 12rambau commented Dec 3, 2024

Fix: #362

doyBySeasons

I slightly tuned the doyByYear method by adding 2 new parameters: seasonStart and seasonEnd. These 2 parameters are set as integer-like value and mark the start and the end of the season.

I decided to go for integer because that simplify downstream code and Python GEE API and pure python datetime can both return such value:

import ee 
ee.Date("2022-06-01").getRelative("day", "year")
from datetime import datetime as dt 
dt(2022, 6, 1).timetuple().tm_yday

plot_doy_by_seasons

Here the trick was to manage the ticks and thankfully matplotlib was super easy to tune. I recover the max and min value from the x value of the graph and simply restric what I display between these 2 edges.

side effect

As I modified the way doy graph are drawn it has slightly modified the figure for existing tests. I'm satisfied with the adjustment (+5, -5 days of margin in the graph) so I simply reloaded the images.

documentation

I upgraded the documentation usage section and added few executed code for the image_collection file that is anyway to big to manage in one PR.

demonstration

with correctly prepared data you can get the following:

fig, ax = plt.subplots(figsize=(10,4))

indices.geetools.plot_doy_by_seasons(
    band = "NDVI",
    region = grassland.geometry(),
    seasonStart = ee.Date("2022-04-15").getRelative("day", "year"),
    seasonEnd = ee.Date("2022-09-15").getRelative("day", "year"),
    reducer = "mean",
    scale = 500,
    ax = ax,
    colors = ['#39a8a7', '#9c4f97']
)

# once created the axes can be modified as needed using pure matplotlib functions
ax.set_ylabel("NDVI (x1e4)")
ax.set_title("Average NDVI Values during growing season in Grassland")

plt.show()

ad058ae1584ea254c39e1f685ecc39f8ad76049669f2fbb4b8dfd5fcdfd00d3f

@12rambau 12rambau marked this pull request as ready for review December 3, 2024 21:43
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.21%. Comparing base (609bd8d) to head (352ce61).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #393      +/-   ##
==========================================
- Coverage   89.21%   89.21%   -0.01%     
==========================================
  Files          27       27              
  Lines        1753     1762       +9     
  Branches       92       92              
==========================================
+ Hits         1564     1572       +8     
- Misses        160      161       +1     
  Partials       29       29              

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

@12rambau 12rambau merged commit c86fcc2 into main Dec 9, 2024
11 checks passed
@12rambau 12rambau deleted the season branch December 9, 2024 11:41
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.

replace the doy_by_year graph by a doy_by_season
1 participant