Skip to content

Commit

Permalink
Merge pull request #4 from lnazzaro/main
Browse files Browse the repository at this point in the history
compatibility fixes, minor updates
  • Loading branch information
lnazzaro authored Jun 28, 2024
2 parents db340cb + 8bf9ac3 commit 73e55ce
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 48 deletions.
42 changes: 0 additions & 42 deletions cool_maps/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,48 +180,6 @@ def calculate_colorbar_ticks(vmin, vmax, c0=False):
return cbticks


def categorical_cmap(nc, nsc, cmap="tab10", continuous=False):
"""
Expand your colormap by changing the alpha value (opacity) of each color.
Returns a colormap with nc*nsc different colors,
where for each category there are nsc colors of same hue.
From ImportanceOfBeingErnest
https://stackoverflow.com/a/47232942/2643708
Args:
nc (int): number of categories (colors)
nsc (int): number of subcategories (shades for each color)
cmap (str, optional): matplotlib colormap. Defaults to "tab10".
continuous (bool, optional): _description_. Defaults to False.
Raises:
ValueError: Too many categories for colormap
Returns:
object: matplotlib colormap
"""

if nc > plt.get_cmap(cmap).N:
raise ValueError("Too many categories for colormap.")
if continuous:
ccolors = plt.get_cmap(cmap)(np.linspace(0,1,nc))
else:
ccolors = plt.get_cmap(cmap)(np.arange(nc, dtype=int))
cols = np.zeros((nc*nsc, 3))
for i, c in enumerate(ccolors):
chsv = matplotlib.colors.rgb_to_hsv(c[:3])
arhsv = np.tile(chsv,nsc).reshape(nsc,3)
arhsv[:,1] = np.linspace(chsv[1],0.25,nsc)
arhsv[:,2] = np.linspace(chsv[2],1,nsc)
rgb = matplotlib.colors.hsv_to_rgb(arhsv)
cols[i*nsc:(i+1)*nsc,:] = rgb
cmap = matplotlib.colors.ListedColormap(cols)
return cmap


def dd2dms(vals):
"""
Convert decimal degrees to degree-minute-second
Expand Down
3 changes: 2 additions & 1 deletion cool_maps/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def add_ticks(ax, extent,

def create(extent,
proj=proj['map'],
data_proj=proj['data'],
features=True,
edgecolor="black",
landcolor="tan",
Expand Down Expand Up @@ -446,7 +447,7 @@ def create(extent,
# Set extent before we 'add features.' This is necessary because
# add_features adds land, coastlines, rivers, lakes, etc. based off
# of the current extent of the window.
ax.set_extent(extent)
ax.set_extent(extent, crs=data_proj)

# Create dictionary for feature arguments
fargs = {
Expand Down
2 changes: 1 addition & 1 deletion environment_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies:
- matplotlib
- cmocean
- oceans
- numpy
- numpy<2.0

2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ cartopy
matplotlib
cmocean
oceans
numpy
numpy<2.0
jupyterlab
nb_conda_kernels
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"matplotlib",
"cmocean",
"oceans",
"numpy",
"numpy<2.0",
"erddapy"
]

Expand Down
4 changes: 2 additions & 2 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ def get_config_from_root(root):
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.SafeConfigParser()
parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory

def get(parser, name):
Expand Down

0 comments on commit 73e55ce

Please sign in to comment.