[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #WWH-979089]: Python Kg/m^2/s to Inches Conversion Problem

Hello hello! Thanks for reaching out to us.

What sort of trouble are you having? Recreating parts of your provided code I 
was able to physically follow your conversion (kg/m2/s * 86400s/24h * 39.37008 
inches/m * 1 m3 / 1000 kg (density of water)) and come to inches/hour, and 
follow your code to make my own plot. I was able also to recreate the same 
using MetPy's units support 
(https://unidata.github.io/MetPy/latest/tutorials/unit_tutorial.html) as below 
and arrived at the same result:

  from metpy.units import units

  precip_units = units('kg / m^2 / s')
  precip_data = data.variables['Precipitation_rate_surface'][:].squeeze()
  precip_with_units = precip_units * 
data.variables['Precipitation_rate_surface'][:].squeeze()  # this will create a 
Pint Quantity giving our masked array physical units

  density_water = units('kg / m^3') * 1000.
  precip_converted = (precip_with_units / density_water).to('inches / hour')  # 
.to() will perform the calculation to convert our values to inches/hour

where we have to use the density of water (with units!) to convert the given 
mass flux (kg/m^2/s) to a volume flux (m^3/m^2/s) which in our 1-m^2 
cross-section is our depth flux (m/s) ready to convert to inches/hour. So, from 
what I can tell, everything here looks good. If you are having a different 
issue or this doesn't help, please don't hesitate to follow up!

All the best,


> I'm having trouble converting kg/m^2/s into inches per hour to plot
> precipitation data.
> I found the formula here I used here
> https://www.researchgate.net/post/How_do_I_convert_ERA_Interim_precipitation_estimates_from_kg_m2_s_to_mm_day
> Any help on how I can correctly convert the data would be greatly
> appreciated!

Ticket Details
Ticket ID: WWH-979089
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.