import komod
%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
Serve to open different file types, mainly those produced by MITgcm.
mitbincoord - opens MITgcm binary XC.data and YC.data files
rmeta - reads .meta file and return information about .data file
mitbin - opens MITgcm binary data file
phcascii - opens PHC (http://psc.apl.washington.edu/Climatology.html) ascii file that have no delimiter
nc2d - Convert 2d fields from adxx* and xx* fles to netCDF format with use of Nio module.
var_nc2d - Convert 2d fields produced by MITgcm to netCDF format with use of Nio module.
nc3d - Convert 3d fields from adxx* and xx* fles to netCDF format with use of Nio module.
var_nc3d - Convert 2d fields produced by MITgcm to netCDF format with use of Nio module.
gatrib - Return attrubutes for known variables.
Opens MITgcm binary XC.data and YC.data files. Files should be located in the same directory with your code, and you have to know it's dimensions. Now it's better to use mitbin2 for this, but I leave this function for backward compatibility.
lon, lat = komod.mitbincoord(416, 480, bswap=1)
subplot(1,2,1)
imshow(lon)
subplot(1,2,2)
imshow(lat)
<matplotlib.image.AxesImage at 0x9f488cc>
Reads .meta file and return information about .data file.
ndim, xdim, ydim, zdim, datatype, nrecords, timeStepNumber = komod.rmeta('AREAtave.0000002191.meta')
print('Number of dimensions = '+str(ndim))
print('Xdim = '+str(xdim))
print('Ydim = '+str(ydim))
print('Zdim = '+str(zdim))
print('Datatype - '+datatype)
print('Number of records = '+str(nrecords))
print('Time step number = '+str(timeStepNumber))
Number of dimensions = 2 Xdim = 416 Ydim = 480 Zdim = 1 Datatype - float32 Number of records = 1 Time step number = 2191
Opens MITgcm binary file that represents one time step. Now depricated.
area = komod.mitbin('AREAtave.0000002191.data', 416, 480, datatype = 'float32')
pcolormesh(area[0,0,:,:])
<matplotlib.collections.QuadMesh at 0xa13d04c>
Uses rmeta to get inforamtion about the file and return field extracted from it.
area = komod.mitbin2('AREAtave.0000002191.data')
temp = komod.mitbin2('Ttave.0000002191.data')
figure(figsize=(10,5))
subplot(1,2,1)
pcolormesh(area[0,0,:,:])
subplot(1,2,2)
pcolormesh(temp[0,5,:,:])
<matplotlib.collections.QuadMesh at 0xa1c980c>
Convert 2d fields produced by MITgcm to netCDF format with use of Nio module. Names of the files should be defined in form of the list, even if we have only one variable. I put everything on the C grid!
You have to have following files in the the directory where you run your code:
XC.data
XC.meta
YC.data
YC.meta
DRC.data
DRC.meta
maskCtrlC.data
maskCtrlC.meta
komod.var_nc2d(parameters=['AREAtave'], FillValue=-999.)
By default output file name is MIT_output_2d.nc. We have to add custom FillValue since default -1.0e+23 is not always a good choise.
!ncdump -h MIT_output_2d.nc
netcdf MIT_output_2d { dimensions: x = 416 ; y = 480 ; time = 1 ; variables: double time(time) ; time:units = "seconds since 2002-10-01 07:00" ; double latitude(x, y) ; latitude:long_name = "latitude" ; latitude:units = "degrees_north" ; latitude:standard_name = "grid_latitude" ; double longitude(x, y) ; longitude:long_name = "longitude" ; longitude:units = "degrees_east" ; longitude:standard_name = "grid_longitude" ; double AREAtave(time, x, y) ; AREAtave:long_name = "Ice Concentration" ; AREAtave:units = " " ; AREAtave:_FillValue = -1.e+23 ; AREAtave:missing_value = -1.e+23 ; // global attributes: :title = "MITgcm variables in netCDF format" ; }
Convert 3d fields produced by MITgcm to netCDF format with use of Nio module. Names of the files should be defined in form of the list, even if we have only one variable. I put everything on the C grid!
You have to have following files in the the directory where you run your code:
XC.data
XC.meta
YC.data
YC.meta
DRC.data
DRC.meta
maskCtrlC.data
maskCtrlC.meta
komod.var_nc3d(parameters=['Ttave'], FillValue=-999.)
By default output file name is MIT_output_3d.nc
!ncdump -h MIT_output_3d.nc
netcdf MIT_output_3d { dimensions: x = 416 ; y = 480 ; z = 50 ; time = 1 ; variables: double time(time) ; time:units = "seconds since 2002-10-01 07:00" ; double z(z) ; z:units = "meters" ; double latitude(x, y) ; latitude:long_name = "latitude" ; latitude:units = "degrees_north" ; latitude:standard_name = "grid_latitude" ; double longitude(x, y) ; longitude:long_name = "longitude" ; longitude:units = "degrees_east" ; longitude:standard_name = "grid_longitude" ; double Ttave(time, z, x, y) ; Ttave:long_name = "Potential Temperature" ; Ttave:units = "deg. C" ; Ttave:_FillValue = -999. ; Ttave:missing_value = -999. ; // global attributes: :title = "MITgcm variables in netCDF format" ; }