pythonpython-3.xmetpy

AttributeError: crs attribute is not available


All, I am using metpy 0.10.0, I am trying to calculate the laplacina of a field using mpcalc.laplacian function, yet I get the following error : AttributeError: crs attribute is not available.

Here is my minmal code:

import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import metpy.calc as mpcalc

myfile   = xr.open_dataset(diri+"vor_geo_era5_2023_jan.nc")
var_z    = myfile['z']   # geopotential m**2 S**-2
   
timeP     = myfile['time']
lonP      = myfile['longitude'].data
latPP     = myfile['latitude'].data
lap       = mpcalc.laplacian(var_z[:,:,:],axes=('latitude','longitude'))

I tried to use var_z.metpy.assign_latitudde_longitude(force=False) as illustrated here text , yet I get the following error AttributeError: 'MetPyAccessor' object has no attribute 'assign_latitudde_longitude' Thanks


Solution

  • The comment above is correct, the error is showing you have a typo, the correct method name is assign_latitude_longitude().

    That said, this method was added in MetPy 1.0, so you'll need to upgrade to a more recent version of MetPy in order for this to work.