Skip to content

Commit

Permalink
use colorcet instead of dismp for cyclic
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie committed Jan 30, 2024
1 parent 2575ec0 commit 41b14de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
1 change: 1 addition & 0 deletions conda-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
# - sentineleof>=0.7.0
# - shapely>=1.8
- isce3>=0.14.0
- colorcet
- compass>=0.4.1
- dask
- dolphin>=0.5.1
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Conda ones
# SYNC THIS WITH conda-env
# These are the packages easily-installable through pip
colorcet
dask>=2022.6.0
h5py>=3.6
numpy>=1.20
Expand Down
37 changes: 4 additions & 33 deletions src/sweets/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import colorcet
import geopandas as gpd
import ipywidgets
import matplotlib as mpl
Expand All @@ -14,7 +15,6 @@
from cartopy.io import shapereader
from cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTER
from dolphin import io
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.image import AxesImage
from numpy.typing import ArrayLike
from shapely.geometry import Polygon, box
Expand All @@ -26,7 +26,7 @@
def plot_ifg(
img: Optional[ArrayLike] = None,
filename: Optional[Filename] = None,
phase_cmap: str = "dismph",
phase_cmap: str = colorcet.m_CET_C8,
ax: Optional[plt.Axes] = None,
add_colorbar: bool = True,
title: str = "",
Expand Down Expand Up @@ -324,6 +324,7 @@ def browse_arrays(
ref_unw : Optional[tuple[int, int]]
Reference point for all .unw files.
If not passed, subtracts the mean of each file.
cmap : str or matplotlib.cmap
subsample_factor : int or tuple[int, int]
Amount to downsample when loading images.
"""
Expand All @@ -343,7 +344,7 @@ def browse_arrays(

if num_panels == 2:
# plot once with colorbar
axim_img = axes[0].imshow(img, cmap="dismph", vmin=-3.14, vmax=3.14)
axim_img = axes[0].imshow(img, cmap=cmap, vmin=-3.14, vmax=3.14)
amp_vmax = np.percentile(np.abs(img_stack), 99)
axim_amp = axes[1].imshow(amp, cmap=cmap, vmax=amp_vmax)

Expand All @@ -367,36 +368,6 @@ def browse_plot(idx=0):
fig.suptitle(titles[idx])


def _make_dismph_colors():
"""Create a cyclic colormap for insar phase."""
red, green, blue = [], [], []
for i in range(120):
red.append(i * 2.13 * 155.0 / 255.0 + 100)
green.append((119.0 - i) * 2.13 * 155.0 / 255.0 + 100.0)
blue.append(255)
for i in range(120):
red.append(255)
green.append(i * 2.13 * 155.0 / 255.0 + 100.0)
blue.append((119 - i) * 2.13 * 155.0 / 255.0 + 100.0)
for i in range(120):
red.append((119 - i) * 2.13 * 155.0 / 255.0 + 100.0)
green.append(255)
blue.append(i * 2.13 * 155.0 / 255.0 + 100.0)
return np.vstack((red, green, blue))


try:
plt.get_cmap("dismph")
except ValueError:
DISMPH = LinearSegmentedColormap.from_list("dismph", _make_dismph_colors().T / 256)
plt.register_cmap(cmap=DISMPH)


# # @lru_cache(maxsize=30)
# def io.load_gdal(filename: , subsample_factor=subsample_factorFilename):
# return io.load_gdal(filename)


def plot_area_of_interest(
state: Optional[str] = None,
bbox: Optional[Tuple[float, float, float, float]] = None,
Expand Down

0 comments on commit 41b14de

Please sign in to comment.