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

Add Level-3 and Level-4 bands for Land Cover product. #161

Merged
merged 24 commits into from
Oct 29, 2024
Merged

Conversation

tebadi
Copy link
Contributor

@tebadi tebadi commented Oct 23, 2024

This change will create the level4 and level3 land cover bands.

The fix_l3 will be applied on top of this PR which will fix the nodata issue. This fix will be applied to Level4 as well.

Links to definitions and thresholds used to generate level-4 bands:

@tebadi tebadi requested review from emmaai and JM-GA October 25, 2024 04:17
@tebadi tebadi changed the title Lc l34 Add Level-3 and Level-4 bands for Land Cover product. Oct 25, 2024
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 99.35795% with 4 lines in your changes missing coverage. Please review.

Project coverage is 82.38%. Comparing base (d799a99) to head (15f0eba).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
odc/stats/plugins/lc_level34.py 91.66% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #161      +/-   ##
===========================================
+ Coverage    80.02%   82.38%   +2.35%     
===========================================
  Files           49       67      +18     
  Lines         4361     4951     +590     
===========================================
+ Hits          3490     4079     +589     
- Misses         871      872       +1     

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

Copy link
Contributor

@emmaai emmaai left a comment

Choose a reason for hiding this comment

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

as in individual comment

dtype="uint8",
**{
"watseas_trh": water_seasonality_threshold,
"watersea_nodata": WATER_FREQ_NODATA,
Copy link
Contributor

Choose a reason for hiding this comment

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

the correct nodata=255 from the raster, also it won't work as water_season_mask has been converted to uint8 from last step, -999 was lost had it been the effective nodata.

Copy link
Contributor Author

@tebadi tebadi Oct 29, 2024

Choose a reason for hiding this comment

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

Good point, refactored the code to effectively replace "nodata"

**{"_u": 210},
)

intertidal_mask = expr_eval(
Copy link
Contributor

Choose a reason for hiding this comment

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

this mask is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This mask is used in level4 water classification.

Copy link
Contributor

@emmaai emmaai Oct 29, 2024

Choose a reason for hiding this comment

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

I mean it's redundant in a sense that l3 and l4 doesn't have to be generated in that order. The water persistence and consequently l4 water classification can happen well ahead of l3 aggregation.

water_persistence = l4_water_persistence.water_persistence(
and
level4 = l4_water.water_classification(
doesn't depend on the aggregated results of l3, so l3 aggregation needs not to happen first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is addressed now.

def bare_gradation(xx: xr.Dataset, bare_threshold, veg_cover):

# Now add the bare gradation
fcp_nodaata = -999
Copy link
Contributor

Choose a reason for hiding this comment

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

is it a typo? I don't see anywhere changing the fcp nodata value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the redundant statement.

)
# Apply bare gradation expected output classes
# Map bare gradation classes
bs_mapping = {100: 10, 120: 12, 150: 15}
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be easier to allocate a new array instead of the extra mapping, also reduce the confusion. It's bit hard to follow that it's essentially to avoid the mixing of small and big values in the original array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I've modified the code and deleted the mapping here and everywhere else.


# Define mapping from current output to expected a3 output
# Map vegetation cover classes
veg_mapping = {160: 16, 150: 15, 130: 13, 120: 12, 100: 10}
Copy link
Contributor

Choose a reason for hiding this comment

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

same as bare_gradition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted the mapping.


# Apply water persistence expcted classes
# Map values to the classes expected in water persistence in land cover Level-4 output
waterper_wat_mapping = {100: 1, 70: 7, 80: 8, 90: 9}
Copy link
Contributor

Choose a reason for hiding this comment

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

same as bare_gradition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted the mapping.

Copy link
Contributor

@emmaai emmaai left a comment

Choose a reason for hiding this comment

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

let's roll see how it goes :)

@tebadi tebadi merged commit 182de0d into develop Oct 29, 2024
5 checks passed
@tebadi tebadi deleted the lc_l34 branch October 29, 2024 23: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.

3 participants