meteoinfo / MeteoInfo

MeteoInfo: GIS, scientific computation and visualization environment.
http://www.meteothink.org/
GNU Lesser General Public License v3.0
311 stars 93 forks source link

AWX to PNG #8

Closed jovi521 closed 4 years ago

jovi521 commented 4 years ago

I want to change a .awx file to .png. But I don't konw how to paser it. Please help me, provide an idea.

Yaqiang commented 4 years ago

Read 2d data array from the .awx file, plot the data, save the plot to .png file.

Following is an example script:

fn = 'D:/Temp/FY/FY2D_TBB_IR1_OTG_20080630_1315.AWX' f = addfile_awx(fn) data = f['var'][:,:]

Plot

axesm() geoshow('country', edgecolor='k') geoshow('cn_province', edgecolor='k') layer = imshowm(data, 20) colorbar(layer, label='K') title('TBB - AWX')

Save png file

savefig('D:/Temp/test/fy2d_tbb.png', width=600, height=700, dpi=150)

jovi521 commented 4 years ago

image image `def geoshow(*args, **kwargs): ''' Display map layer or longitude latitude data.

Syntax:
--------    
    geoshow(shapefilename) - Displays the map data from a shape file.
    geoshow(layer) - Displays the map data from a map layer which may created by ``shaperead`` function.
    geoshow(S) - Displays the vector geographic features stored in S as points, multipoints, lines, or 
      polygons.
    geoshow(lat, lon) - Displays the latitude and longitude vectors.
'''
global gca
if g_figure is None:
    figure()

if gca is None:    
    gca = axesm()
else:
    if gca.axestype != 'map':
        gca = axesm()

r = gca.geoshow(*args, **kwargs)
if not r is None:
    draw_if_interactive()

return r`

`def imshowm(*args, **kwargs): global gca if g_figure is None: figure()

if gca is None:    
    gca = axesm()
else:
    if gca.axestype != 'map':
        gca = axesm()

r = gca.imshow(*args, **kwargs)
if not r is None:
    draw_if_interactive()

return r`

`def title(label, loc='center', fontname=None, fontsize=14, bold=True, color='black', **kwargs): """ Set a title of the current axes.

:param label: (*string*) Title label string.
:param loc: (*string') Which title to set ['center' | 'left' | 'right'],
    default to 'center'.
:param fontname: (*string*) Font name. Default is ``None``, using ``Arial`` .
:param fontsize: (*int*) Font size. Default is ``14`` .
:param bold: (*boolean*) Is bold font or not. Default is ``True`` .
:param color: (*color*) Title string color. Default is ``black`` .  
:param linespace: (*int*) Line space of multiple line title.
"""
r = gca.set_title(label, loc, fontname, fontsize, bold, color, **kwargs)
draw_if_interactive()
return r`

image

jovi521 commented 4 years ago

Python?......I'm a javaer.I don't konw how to use it.So I still don't konw how to parse AWX to PNG

Yaqiang commented 4 years ago

I suggest you to learn Jython to understand the code.

jovi521 commented 4 years ago

OK. I have read you some code. And I saw you parsed it successfully,such as: image Is it right?But, AWX file is belongs to SAT96 or SAT2004. Their standard like this: image You just had the data: image No NO1-File-Head and NO2-File-Head. Is it right or haven't achieve it?

Yaqiang commented 4 years ago

Please find the awx file decoding code here: https://github.com/meteoinfo/MeteoInfo/blob/master/MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/awx/AWXDataInfo.java