2

I have netcdf4 file with some variables like: Geo Coordinates System X/Y. I need to convert it to lat/lon. How can i do that with python?

This information from my netCDF4 file:

    import numpy as np
    from netCDF4 import Dataset

     path = '/home/data/Mmultic3kmNC4_msg04_201905080200.
        ...: nc'

    In [78]: f=netCDF4.Dataset(path,'r')

     f.variables.keys()
    Out[80]: odict_keys(['time', 'dtime', 'IR_016', 'commentaires', 'satellite', 'geos', 'ImageNavigation', 'GeosCoordinateSystem', 'Y', 'X', 'Albedo_to_Native_count_IR_016', 'IR_039', 'Temp_to_Native_count_IR_039', 'IR_087', 'Temp_to_Native_count_IR_087', 'IR_097', 'Temp_to_Native_count_IR_097', 'IR_108', 'Temp_to_Native_count_IR_108', 'IR_120', 'Temp_to_Native_count_IR_120', 'IR_134', 'Temp_to_Native_count_IR_134', 'VIS006', 'Albedo_to_Native_count_VIS006', 'VIS008', 'Albedo_to_Native_count_VIS008', 'WV_062', 'Temp_to_Native_count_WV_062', 'WV_073', 'Temp_to_Native_count_WV_073'])

    In [81]: IR=f.variables['IR_108']

    In [82]: IR
    Out[82]: 
    <class 'netCDF4._netCDF4.Variable'>
    int16 IR_108(ny, nx)
        standard_name: toa_brightness_temperature
        long_name: 10.8 microns infra-red channel MSG Imager
        units: K
        scale_factor: 0.01
        add_offset: 273.15
        valid_min: -27315
        valid_max: 32767
        _FillValue: -32768
        available: yes
        comment: channel 9
        nuc: 931.122
        alpha: 0.9983
        beta: 0.6256
        CalibrationParametersOrigin: rttov
        _CoordinateSystems: GeosCoordinateSystem
        grid_mapping: GeosCoordinateSystem
        resolution: 3.0
        Offset : radiance = offset + CN x slope: -10.456819486590666
        Slope : radiance = offset + CN x slope: 0.2050356762076601
    unlimited dimensions: 
    current shape = (3712, 3712)
    filling on

    print(IR.dimensions)
    ('ny', 'nx')
x=f.variables['X']                                                      

In [3]: x                                                                       
Out[3]: 
<class 'netCDF4._netCDF4.Variable'>
float32 X(nx)
    standard_name: projection_x_coordinate
    units: m
    _CoordinateAxisType: GeoX
unlimited dimensions: 
current shape = (3712,)
filling on, default _FillValue of 9.969209968386869e+36 used

In [4]: y = f.variables['Y']                                                    

In [5]: y                                                                       
Out[5]: 
<class 'netCDF4._netCDF4.Variable'>
float32 Y(ny)
    standard_name: projection_y_coordinate
    units: m
    _CoordinateAxisType: GeoY
unlimited dimensions: 
current shape = (3712,)
filling on, default _FillValue of 9.969209968386869e+36 used

y = f.variables['Y'][:]                                                                   

In [12]: y                                                                                         
Out[12]: 
masked_array(data=[ 5568754. ,  5565753.5,  5562753. , ..., -5559743. ,
                   -5562743. , -5565744. ],
             mask=False,
       fill_value=1e+20,
            dtype=float32)

link for file netCDF4

What do I need to use to convert X/Y to lat /lon coordinates?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.