[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #MZO-814691]: Re: Returned mail: see transcript for details
- Subject: [python #MZO-814691]: Re: Returned mail: see transcript for details
- Date: Thu, 03 Oct 2019 11:24:49 -0600
Hi!
The syntax using Xarray would be:
dataset['QV'].attrs['units'] = 'dimensionless'
Hope that helps!
Zach
> Hi,
> Can you please just clarify the syntax I need to convert from units of 'kg
> kg-1' to '1'?
> Thanks a lot,
>
> On Wed, Oct 2, 2019 at 1:28 PM wrote:
>
> > Hi,
> > Here is a link to the data. There is a '_flx' file where there are the
> > QLML and TLML and PS variables that I use to calculate at the surface. In
> > the other file are data on multiple levels.
> > The 2 functions are below. _surface works fine but I get an error for
> > _levels.
> >
> > Thanks a lot,
> >
> >
> >
> >
> >
> >
> > # calculate dew point temperature
> >
> > def get_dew_surface(dataset):
> > #mpcalc.dewpoint_from_specific_humidity(specific_humidity,
> > temperature, pressure)
> > #QLML and TLML shape 91, 89 lat 15 to 60. lon -170 to -115
> > #SLP shape 90, 88 lat 15 to 59.5. lon -170 to -115.6
> >
> > sh=dataset['QLML']
> > t=dataset['TLML'] # Kelvin
> >
> > t.metpy.convert_units('degC')
> >
> >
> > p=dataset['PS']
> >
> > dataset['Tdew'] = mpcalc.dewpoint_from_specific_humidity(sh, t, p)
> >
> >
> > ## if temperature is less than dew point temperature, get condensation
> >
> > dataset['T-Tdew'] = t-dataset['Tdew']
> >
> > return
> >
> >
> >
> > # dew point vertical profile
> > def get_dew_levels(dataset):
> > #mpcalc.dewpoint_from_specific_humidity(specific_humidity,
> > temperature, pressure)
> > #QLML and TLML shape 91, 89 lat 15 to 60. lon -170 to -115
> > #SLP shape 90, 88 lat 15 to 59.5. lon -170 to -115.6
> >
> > sh=dataset['QV'] # 42,91,89
> > t=dataset['T'] # Kelvin 42,91,89
> >
> > t.metpy.convert_units('degC')
> >
> > # need pressure with height
> > p=dataset['T'].lev # 42 levels
> >
> > dataset['Tdew'] = mpcalc.dewpoint_from_specific_humidity(sh[0], t[0],
> > p[0])
> >
> > ## if temperature is less than dew point temperature, get condensation
> >
> > dataset['T-Tdew'] = t-dataset['Tdew']
> >
> > return
> >
> >
> >
> >
> >
> >
> >
> >
> > address@hidden> wrote:
> >
> >> Hi!
> >>
> >> Sounds like the units in your file are a little funky. Is there any chance
> >> that you could provide a link to the data (Drive/Dropbox) so that I could
> >> play with it and see how to get around this error? I can get you a more
> >> exact answer if I can get eyes on it. Otherwise, if you know what the
> >> units
> >> should be, you can manually assign the units by stripping and reattaching
> >> (variable.magnitude * units.whatever) and then passing that into the
> >> function. It's somewhat surprising though that the (kg/kg) units aren't
> >> being handled correctly, which is why I would like to see it in person to
> >> see if we have a bug somewhere.
> >>
> >> Thanks,
> >> Zach
> >>
> >> On Fri, Sep 27, 2019 at 4:02 PM <address@hidden> wrote:
> >>
> >> > New Ticket: Re: Returned mail: see transcript for details
> >> >
> >> > > ---------- Forwarded message ----------
> >> > > To: address@hidden
> >> > > Cc:
> >> > > Bcc:
> >> > > Date: Fri, 27 Sep 2019 11:06:24 -0700
> >> > > Subject: specific humidity units
> >> > invmpcalc.dewpoint_from_specific_humidity
> >> > > Hi,
> >> > > I am using mpcalc.dewpoint_from_specific_humidity successfully when I
> >> use
> >> > > surface values of specific humidity, temperature and pressure.
> >> However,
> >> > > when I want to compute this on multiple levels I get this error:
> >> > >
> >> > > DimensionalityError: Cannot convert from 'kilogram ** 2' to
> >> > 'dimensionless'
> >> > >
> >> > > I have looked into the data that I put straight into xarrays from
> >> > > downloading the raw data and the surface specific humidity has units
> >> of
> >> > '1'
> >> > > and the specific humidity on multiple levels has units of 'kg/kg'.
> >> > >
> >> > > Do you know how I can get around this error?
> >> > >
> >> > > Thanks a lot,
> >> >
> >> > Ticket Details
> >> > ===================
> >> > Ticket ID: MZO-814691
> >> > Department: Support Python
> >> > Priority: Low
> >> > Status: Open
> >> > Link:
> >> >
> >> https://andy.unidata.ucar.edu/staff/index.php?_m=tickets&_a=viewticket&ticketid=30747
> >> > ===================
> >> > NOTE: All email exchanges with Unidata User Support are recorded in the
> >> > Unidata inquiry tracking system and then made publicly available through
> >> > the web. If you do not want to have your interactions made available in
> >> > this way, you must let us know in each email you send to us.
> >> >
> >> >
> >>
> >>
> >>
> >> Ticket Details
> >> ===================
> >> Ticket ID: MZO-814691
> >> Department: Support Python
> >> Priority: Low
> >> Status: Open
> >> ===================
> >> NOTE: All email exchanges with Unidata User Support are recorded in the
> >> Unidata inquiry tracking system and then made publicly available through
> >> the web. If you do not want to have your interactions made available in
> >> this way, you must let us know in each email you send to us.
> >>
> >>
> >>
>
Ticket Details
===================
Ticket ID: MZO-814691
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.