Skip to content

Commit

Permalink
More consistent land-water state
Browse files Browse the repository at this point in the history
Water and coast pixels are lumped together. This is
consistent with the definition of water and land
in the fire mask.

Note that this change leads to differences in the
area accumulators. Inland fires should not be
affected by this change.
  • Loading branch information
adarmenov committed Jul 11, 2023
1 parent 320e27a commit 7fad938
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/qfed/mxd14_l3.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,15 @@ def _readGranule(self,filename):
# ---------------------------------------------------------------------------------------------
n_fires_initial = frp.size

i = [n for n in range(n_fires_initial) if self.lws[fp_line[n],fp_sample[n]] == QA_WATER]
i = [n for n in range(n_fires_initial) if self.lws[fp_line[n],fp_sample[n]] in (QA_WATER, QA_COAST)]
if len(i) > 0:
if self.verb > 1:
print(" --> found %d FIRE pixel(s) over water" % len(i))

self.gWater += _binareas(lon[i],lat[i],area[i],self.im,self.jm,grid_type=self.grid_type)
print(f"Added {len(area[i])} fire-pixels to water area.")

i = [n for n in range(n_fires_initial) if self.lws[fp_line[n],fp_sample[n]] in (QA_COAST,QA_LAND)]
i = [n for n in range(n_fires_initial) if self.lws[fp_line[n],fp_sample[n]] in (QA_LAND,)]
if len(i) > 0:
lon = lon[i]
lat = lat[i]
Expand All @@ -708,7 +709,7 @@ def _readGranule(self,filename):
area = area[i]
else:
if self.verb > 1:
print(" --> no FIRE pixels over land/coast")
print(" --> no FIRE pixels over land")

return

Expand All @@ -722,6 +723,7 @@ def _readGranule(self,filename):
# Bin area of burning pixels
# --------------------------
self.gLand += _binareas(lon,lat,area,self.im,self.jm,grid_type=self.grid_type)
print(f"Added {len(area)} fire-pixels to land area.")

# Bin FRP for each biome
# ----------------------
Expand Down Expand Up @@ -782,8 +784,8 @@ def _readAreas(self,mxd14,mxd03):
qa = mxd14.select('algorithm QA').get()
self.lws = np.bitwise_and(qa, 3) # land/water state is stored in bits 0-1

i_water = np.logical_and(self.lws==QA_WATER, valid)
i_land = np.logical_and(np.logical_or(self.lws==QA_COAST, self.lws==QA_LAND), valid)
i_water = np.logical_and(np.logical_or(self.lws==QA_WATER, self.lws==QA_COAST), valid)
i_land = np.logical_and(self.lws==QA_LAND, valid)


# Calculate pixel area
Expand All @@ -805,10 +807,10 @@ def _readAreas(self,mxd14,mxd03):
# Bin areas of no-fires and sum
# -----------------------------
self.gLand += _binareas(lon,lat,area,self.im,self.jm,grid_type=self.grid_type)

print(f"Added {len(area)} clear sky land-pixels to land area.")
else:
if self.verb > 1:
print(" --> no NOFIRE pixel for granule")
print(" --> no NOFIRE pixel in granule")

# non-fire water or cloud over water
i = np.logical_or(np.logical_and(fmask==WATER, valid), np.logical_and(np.logical_and(fmask==CLOUD, valid), i_water))
Expand All @@ -824,10 +826,10 @@ def _readAreas(self,mxd14,mxd03):
# Bin areas of water and sum
# --------------------------
self.gWater += _binareas(lon,lat,area,self.im,self.jm,grid_type=self.grid_type)

print(f"Added {len(area)} clear sky|cloudy water-pixels to water area.")
else:
if self.verb > 1:
print(" --> no WATER pixel for granule")
print(" --> no WATER pixel in granule")

# cloud over land only
i = np.logical_and(np.logical_and(fmask==CLOUD, valid), i_land)
Expand All @@ -843,10 +845,10 @@ def _readAreas(self,mxd14,mxd03):
# Bin areas of cloud and sum
# --------------------------
self.gCloud += _binareas(lon,lat,area,self.im,self.jm,grid_type=self.grid_type)

print(f"Added {len(area)} cloudy land-pixels to cloud area.")
else:
if self.verb > 1:
print(" --> no CLOUD pixel for granule")
print(" --> no CLOUD pixel in granule")

return 0

Expand Down

0 comments on commit 7fad938

Please sign in to comment.