Formative Assessment: numpy
Although we provide access to answers for this exercise, we want you to submit the codes you generate via Moodle, so that we can provide feedback. You should avoid looking at the answers before you submit your work. This submitted work does not count towards your course assessment, it is purely to allow us to provide some rapid feedback to you on how you are doing. You will need to put together a few elements from the notes so far to do all parts of this practical, but you should all be capable of doing it well. Pay attention to writing tidy code, with useful, clear comments and document strings.
Exercise 1
Recall from previous sections how to retrieve a MODIS LAI dataset for a particular date. Recall also values of greater than 100 are invalid, and that a scaling of 0.1 should be applied to the LAI.
- Load a MODIS LAI dataset SDS
Lai_500m
for tileh17v03
day of year 41, 2019. - Call the 2D array
data
and confirm that it has a shape (2400, 2400) - build a mask called
mask
of invalid pixels - print the percentage of invalid pixels to 2 decimal places (hint: sum with
sum
) - scale the data array as appropriate to obtain LAI
- set invalid data values to 'not a number'
np.nan
- display the resulting image