What's wrong
from_template tags its output DataArray with two attribute keys that don't follow any recognized metadata standard:
crs_units ('m' or 'degree')
crs_name (the human-readable projection name, e.g. 'NAD83 / Conus Albers')
crs_units also duplicates information that belongs on the coordinate variables, and the coordinate units it mirrors ('degree') isn't CF-valid for lon/lat axes.
Proposed change
Align the template metadata with the CF (Climate and Forecast) Conventions, the metadata standard xarray and the wider geoscience stack already lean on.
- Drop
crs_units from the DataArray attrs. Units belong on the coordinates, where x/y already carry them.
- Make the coordinate metadata CF-correct:
- EPSG:4326:
units of degrees_east/degrees_north with standard_name longitude/latitude (today it emits 'degree').
- Projected:
units of m with standard_name projection_x_coordinate/projection_y_coordinate.
- Replace
crs_name with the CF grid-mapping keys grid_mapping_name (the projection token, e.g. albers_conical_equal_area) and crs_wkt (full WKT, which carries the human-readable name). This matches how the rest of the library identifies a CRS: crs/crs_wkt, with everything else derived via pyproj.
Notes
- The CF keys come from
pyproj.CRS.to_cf(). Same as the current crs_name, they stay best-effort: without pyproj the default path is dependency-free and the keys are omitted.
- Equal Earth (the
preserve='area' fallback) has no CF grid mapping, so grid_mapping_name is left off there and only crs_wkt is emitted.
- This changes the attribute contract of
from_template. The library is pre-1.0, so no deprecation shim.
What's wrong
from_templatetags its outputDataArraywith two attribute keys that don't follow any recognized metadata standard:crs_units('m'or'degree')crs_name(the human-readable projection name, e.g.'NAD83 / Conus Albers')crs_unitsalso duplicates information that belongs on the coordinate variables, and the coordinateunitsit mirrors ('degree') isn't CF-valid for lon/lat axes.Proposed change
Align the template metadata with the CF (Climate and Forecast) Conventions, the metadata standard xarray and the wider geoscience stack already lean on.
crs_unitsfrom the DataArray attrs. Units belong on the coordinates, wherex/yalready carry them.unitsofdegrees_east/degrees_northwithstandard_namelongitude/latitude(today it emits'degree').unitsofmwithstandard_nameprojection_x_coordinate/projection_y_coordinate.crs_namewith the CF grid-mapping keysgrid_mapping_name(the projection token, e.g.albers_conical_equal_area) andcrs_wkt(full WKT, which carries the human-readable name). This matches how the rest of the library identifies a CRS:crs/crs_wkt, with everything else derived via pyproj.Notes
pyproj.CRS.to_cf(). Same as the currentcrs_name, they stay best-effort: without pyproj the default path is dependency-free and the keys are omitted.preserve='area'fallback) has no CF grid mapping, sogrid_mapping_nameis left off there and onlycrs_wktis emitted.from_template. The library is pre-1.0, so no deprecation shim.