My overall objective is to extract all areas that have a night time temperature <= 0 degrees C from the ERA5 hourly collection on Earth Engine, consideirng the time period 1981-2020 over a entire country (not points, polygons). The steps I have followed are -
- Filter entire collection to have images only from 10pm-6am (night time defined in my project) (lines 141)
- Convert images to degrees celcius (lines 146-149)
- Reclassify all pixels such as pixels with night time temp <=0 is 1 and rest is 0 over the entire collection (lines 151-155)
- Reduce the collection by sum to get the number of times a pixel has night time temp <=0 in a day (lines 159-175) 5)Again reclassify like step 3 such that if temperature dropped <=0 in a day, pixel value is 1, else 0 (lines 180-183)
- Again reduce by sum like step 4, such that pixel value is number of days in which nigh time temp dropped <=0 in a month (lines 185-201)
- Finally reduce by sum again, pixel value is number of days temp dropped <=0 in a year (lines 205-221)
- Reclassify again such that all pixels with value > 15 is 1 and rest is 0. This means that all pixels that had more than 15 days of night time temp dropping to <=0 in a year is 1 and rest is 0.
- Last reduction by sum where pixel value means number of years in which there was >15 days of nght time temp dropping <=0 10 ) Export to drive.
I have completed above for India as an example and I have initiated the script only for 2 years- Jan 1981 to dec 1982.
Everything runs. However the export stops after 2.5-3.5 hours with the error
Error: reduce.sum: Error in map(ID=0): Image.gt: If one image has no bands, the other must also have no bands. Got 0 and 1. (Error code: 3)
How do I figure out which images (hours) do not have any bands and exclude these images at any step? Alternatively how do I correct this script so it runs and exports out a binary raster, for a country, indicating areas where min 15 days of a year had night time temp dropping below freezing?
Here is the code editor script starting lines 122