-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
When we link the plot script to the simulation folder, it can't find the colormaps folder with the reflectivity colorscale.
Add this line at the start:
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
Replace the statement in line 262 (elif os.path.exists(colorfile:=f"colormaps/{cmapname}.yaml"):) with
elif (colorfile_info := resolve_custom_colormap_file(cmapname))[0]:
colorfile, _ = colorfile_info
You can add more information to the raise statement (line 279):
_, searched = resolve_custom_colormap_file(cmapname)
raise ValueError(
f"Requested color map {cmapname} is not valid. "
f"Checked built-in matplotlib colormaps and custom files: {searched}"
)
And add this function:
def resolve_custom_colormap_file(cmapname: str):
"""
Resolve custom colormap YAML by checking:
1) explicit user-provided path (with/without .yaml),
2) script-local colormaps directory,
3) current-working-directory colormaps directory.
"""
searched = []
# Allow explicit path-like values in config (absolute or relative)
if os.path.isabs(cmapname) or os.path.sep in cmapname:
explicit = cmapname if cmapname.endswith(".yaml") else f"{cmapname}.yaml"
searched.append(explicit)
if os.path.exists(explicit):
return explicit, searched
candidates = [
os.path.join(SCRIPT_DIR, "colormaps", f"{cmapname}.yaml"),
os.path.join(os.getcwd(), "colormaps", f"{cmapname}.yaml"),
]
# Remove duplicates while preserving order.
candidates = list(dict.fromkeys(candidates))
for candidate in candidates:
searched.append(candidate)
if os.path.exists(candidate):
return candidate, searched
return None, searched
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels