Skip to content

Commit

Permalink
Merge pull request #3 from gregory-halverson/main
Browse files Browse the repository at this point in the history
fixing color-maps
  • Loading branch information
gregory-halverson authored Nov 9, 2024
2 parents 44c4450 + 73c966f commit 2877346
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions ECOv002_granules/ECOv002_granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
from .L3TSM import L3TSM
from .L4TESI import L4TESI
from .L4TWUE import L4TWUE
from .granule import ECOSTRESSGranule
from .open_granule import open_granule
7 changes: 3 additions & 4 deletions ECOv002_granules/L1CTRAD.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
from typing import Union, List, Any

import numpy as np
import rasters as rt
import colored_logging as cl

from ECOv002_granules.tiled_granule import ECOSTRESSTiledGranule
import he5py
import rasters as rt
import rasters
from rasters import Raster, MultiRaster, RasterGeometry, RasterGrid, KDTree
import colored_logging as cl

from .granule import ECOSTRESSGranule
from .tiled_granule import ECOSTRESSTiledGranule

__author__ = "Gregory Halverson"

Expand Down
15 changes: 14 additions & 1 deletion ECOv002_granules/L2TSTARS.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@

from dateutil import parser

from .colors import NDVI_COLORMAP
from .colors import *
from .granule import ECOSTRESSGranule
from .tiled_granule import ECOSTRESSTiledGranule

PRIMARY_VARIABLE = "NDVI"
PREVIEW_CMAP = NDVI_COLORMAP

VARIABLE_CMAPS = {
"NDVI": NDVI_COLORMAP,
"NDVI-UQ": "jet",
"albedo": ALBEDO_COLORMAP,
"albedo-UQ": "jet"
}

class L2STARSGranule(ECOSTRESSGranule):
_PRODUCT_NAME = "L2T_STARS"
_PRIMARY_VARIABLE = "NDVI"
_GRANULE_PREVIEW_CMAP = PREVIEW_CMAP

VARIABLE_CMAPS = VARIABLE_CMAPS

def __init__(self, product_filename: str):
super(L2STARSGranule, self).__init__(product_filename=product_filename)

Expand All @@ -27,6 +36,7 @@ def __init__(self, product_filename: str):
def NDVI(self):
if self._NDVI is None:
self._NDVI = self.variable("NDVI")
self._NDVI.cmap = NDVI_COLORMAP

return self._NDVI

Expand All @@ -41,6 +51,7 @@ def NDVI_UQ(self):
def albedo(self):
if self._albedo is None:
self._albedo = self.variable("albedo")
self._albedo.cmap = ALBEDO_COLORMAP

return self._albedo

Expand All @@ -65,6 +76,8 @@ class L2TSTARS(ECOSTRESSTiledGranule, L2STARSGranule):
_PRIMARY_VARIABLE = PRIMARY_VARIABLE
_GRANULE_PREVIEW_CMAP = PREVIEW_CMAP

VARIABLE_CMAPS = VARIABLE_CMAPS

def __init__(
self,
product_location: str = None,
Expand Down
36 changes: 36 additions & 0 deletions ECOv002_granules/L3TJET.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,42 @@ def __repr__(self):

return display_string

@property
def BESSinst(self) -> Raster:
return self.variable("BESSinst", cmap=ET_COLORMAP)

@property
def ETdaily(self) -> Raster:
return self.variable("ETdaily", cmap=ET_COLORMAP)

@property
def MOD16inst(self) -> Raster:
return self.variable("MOD16inst", cmap=ET_COLORMAP)

@property
def PTJPLSMinst(self) -> Raster:
return self.variable("PTJPLSMinst", cmap=ET_COLORMAP)

@property
def PTJPLSMcanopy(self) -> Raster:
return self.variable("PTJPLSMcanopy", cmap=ET_COLORMAP)

@property
def PTJPLSMsoil(self) -> Raster:
return self.variable("PTJPLSMsoil", cmap=ET_COLORMAP)

@property
def PTJPLSMinterception(self) -> Raster:
return self.variable("PTJPLSMinterception", cmap=ET_COLORMAP)

@property
def STICinst(self) -> Raster:
return self.variable("STICinst", cmap=ET_COLORMAP)

@property
def STICcanopy(self) -> Raster:
return self.variable("STICcanopy", cmap=ET_COLORMAP)

@property
def ETinst(self) -> Raster:
return self.variable("ETinst", cmap=ET_COLORMAP)
Expand Down
5 changes: 5 additions & 0 deletions ECOv002_granules/tiled_granule.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class ECOSTRESSTiledGranule(ECOSTRESSGranule):
_STANDARD_METADATA_GROUP = "StandardMetadata"
_PRODUCT_METADATA_GROUP = "ProductMetadata"

VARIABLE_CMAPS = {}

def __init__(
self,
product_location: str = None,
Expand Down Expand Up @@ -554,6 +556,9 @@ def variable(self, variable: str, geometry: RasterGeometry = None, cmap=None, **
duration = end_time - start_time
logger.info(f"finished reading {self.product} {variable} ({duration:0.2f}s)")

if cmap is None and cmap in self.VARIABLE_CMAPS:
cmap = self.VARIABLE_CMAPS[variable]

if cmap is not None:
print(f"assigning cmap: {cmap}")
image.cmap = cmap
Expand Down

0 comments on commit 2877346

Please sign in to comment.