Skip to content

Multiple issues with vertical coordinate conversions #64

@SebastienRietteMTO

Description

@SebastienRietteMTO

First: it's somewhat messy (for example mass2flux method/function exists in both profile and VGeometry)

VGeometry:

  • call to profiles.pressure2altitude from hybridP_coord_to_3D_altitude_field should use the vertical_mean argument received instead of specifying 'geometric', no?
  • still in hybridP_coord_to_3D_altitude_field, why do we ask the p3D field to be on mass points (hybridP_geometry is expressed on flux points, hybridP_coord_and_surfpressure_to_3D_pressure_field will compute pressure on flux and convert it into mass levels; then profiles.pressure2altitude will convert it back to flux levels). Less conversions are needed if pressure is asked on flux levels.

This double conversion seems to also occur in diag_Hgeopot_from_T_q

In profiles, flux2masspressures makes use of LAPRXPK. This LAPRXPK option must be coded consistently in mass2fluxpressures to ensure agreement between both functions.

Additionaly, this script (with the first issue in VGeometry corrected) gives negative values (between -6 and -5.28):

#!/usr/bin/env python3
import epygram
epygram.init_env()
from epygram.geometries.VGeometry import hybridP_coord_to_3D_altitude_field

import matplotlib.pyplot as plt

name_of_fa='/scratch/work/straussc/PLOTS_WORKDIR/GWRJ_20250205_16.fa'
with epygram.formats.resource(name_of_fa, 'r') as res:
    hybridP_geometry = res.readfield("S058TEMPERATURE").geometry.vcoordinate
    Psurf = res.readfield("SURFPRESSION")
    Psurf.sp2gp()
    Psurf.operation("exp")
    Phi_surf = res.readfield("SPECSURFGEOPOTEN")
    Phi_surf.sp2gp()
    vertical_mean = "arithmetic"


with epygram.resources.meta_resource(name_of_fa, "r", "CL") as res:
    t3D = res.readfield(
        {
            "discipline": 0,
            "parameterCategory": 0,
            "parameterNumber": 0,
            "tablesVersion": 15,
            "typeOfFirstFixedSurface": 119,
        }
    )
    q3D = res.readfield(
        {
            "discipline": 0,
            "parameterCategory": 1,
            "parameterNumber": 0,
            "tablesVersion": 15,
            "typeOfFirstFixedSurface": 119,
        }
    )

t3D.sp2gp()

(lon, lat) = t3D.geometry.get_lonlat_grid()

Z3D = hybridP_coord_to_3D_altitude_field(
    hybridP_geometry,
    Psurf,
    vertical_mean,
    t3D,
    q3D
)

fig, ax = plt.subplots()

c=ax.contourf(lon,lat,Z3D.data[89])
cbar=fig.colorbar(c)
plt.show()
fig.savefig('Z89.png')

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions