def wgs84_ellipsoid_mat():
    a, fi = 6378137, 298.257223563
    # f=flattening=(a-b)/a=1/fi
    f = 1. / fi
    b = (1 - f) * a
    ecc = np.sqrt(1 - pow(b / a, 2))  # eccentricity
    # print(a,fi,f,b,ecc)
    # print(a/(a-b))
    return a, ecc


###############################################

###############################################

bmap = FP.start_HYCOM_map('Arctic')
ODLmap = pyproj.Proj('+init=EPSG:3413')
"""
srs='+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45'+\
    ' +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
"""

# directories
compname = os.getenv('HOSTNAME')
if 'hexagon' in compname:
    #hexagon
    HEX = True
    mdir = '/work/timill/RealTime_Models/results_hindcasts/TP4a0.12/wavesice_erai2/'
    gridpath = None

# make time series plots
year = 2006

# model data
print('Load model daily files...\n')
ddir = '/work/timill/RealTime_Models/TP4a0.12/expt_01.4/data'
fli1 = mr.file_list(ddir, 'DAILY', '.a')

# monthly averaged conc
print('Load OSISAF monthly files...\n')
osidir = '/work/shared/nersc/OSISAF/'
osipat = 'osisaf-nh_aggregated_ice_concentration_nh_polstere-100'
fli2 = mr.file_list(osidir, osipat, '.nc')

# basemap
gs = GrdSpc.GridSpec(1, 1)
bmap = Fplt.start_HYCOM_map('Arctic')
fig = plt.figure()
ax = fig.add_subplot(gs[0, 0])

dto0 = DTM.datetime(year, 1, 1)
dto0_, idx0 = fli2.nearestDate(dto0)
# print(idx0)

hgi = MHU.HYCOM_grid_info(gridpath=ddir)
cell_areas = hgi.get_areas()

ice_areas = []
ice_vols = []
ice_vols2 = []
dates = []
Ejemplo n.º 3
0
import MIZchar as mc
import fns_plotting as FP

if 0:
    bmap = FP.start_HYCOM_map('gre')
else:
    lon0 = -10.
    lat0 = 77.
    lon1 = 2.
    lat1 = 83.
    bbox = [lon0, lat0, lon1, lat1]
    bmap = FP.start_map(bbox)

ddir = '/home/nersc/lucia/MIZvalid'
tfil = ddir + '/TP4archv_wav.2015_351_180000_dmax.txt'
tfo = mc.single_file(tfil)

METH = 5
Psolns = tfo.get_solutions(METH=METH)
Psolns.plot_solutions(bmap)
Ejemplo n.º 4
0
sav2bin(aid,{'LANDMASK':landmask},fields)

aid.close()

bid   = open(outdir+'/'+gridname+'.b','w')
write_bfile(bid,fields,nx,ny)
bid.close()
print("\n grid-files "+outdir+'/'+gridname+'.[a,b] saved\n')
# ===============================================================

# ===============================================================
if TEST_PLOT>0:
   # plot grid outline on top of data from netcdf file
   import mod_reading as mr
   import fns_plotting as Fplt
   bmap  = Fplt.start_HYCOM_map(HYCOMreg)
   print('Using '+ncfil)
   nci      = mr.nc_getinfo(ncfil,lonlat_file=lonlat_file)
   print(' - contains:')
   print(nci.variables)
   po,bmap  = nci.plot_var(vbl,bmap=bmap,show=False,time_index=time_index,date_label=dlabel,clabel=vbl)

   # plot new selection
   xyVerts  = []
   xyVerts.append((xmin,ymin))
   xyVerts.append((xmin,ymax))
   xyVerts.append((xmax,ymax))
   xyVerts.append((xmax,ymin))

   Verts = []
   for x,y in xyVerts:
Ejemplo n.º 5
0
      if (i == 2.0):
        mask[i, :] = 1
      else:
        mask[i, :] = 0

  return grid

import fns_plotting as Fplt
import mod_reading  as mr
from matplotlib import pyplot as plt

gdir  = '/work/shared/nersc/msc/ModelInput/../REANALYSIS/topo'
afil  = gdir+'/regional.grid.a'

plon  = mr.get_array_from_HYCOM_binary(afil,1)
plat  = mr.get_array_from_HYCOM_binary(afil,2)
qlon  = mr.get_array_from_HYCOM_binary(afil,3)
qlat  = mr.get_array_from_HYCOM_binary(afil,4)
ulon  = mr.get_array_from_HYCOM_binary(afil,5)
ulat  = mr.get_array_from_HYCOM_binary(afil,6)
vlon  = mr.get_array_from_HYCOM_binary(afil,7)
vlat  = mr.get_array_from_HYCOM_binary(afil,8)

if 0:
   bmap  = Fplt.start_HYCOM_map('TP4')
   bmap.plot(plon[:-1,:-1],plat[:-1,:-1],'.k',latlon=True)
   bmap.plot(qlon,qlat,'or',latlon=True)
   bmap.plot(ulon,ulat,'^g',latlon=True)
   bmap.plot(vlon,vlat,'vb',latlon=True)
   plt.show()
Ejemplo n.º 6
0
print(vlst)
recno = vlst[vbl]
V = Mrdg.get_array_from_HYCOM_binary(afil, recno, dims=(nx, ny))
#print('recno='+str(recno))
##################################################################

if 0:
    # plot V with imshow:
    plt.imshow(V)
    plt.title(vbl)
    plt.colorbar()
    plt.show()
elif 1:
    # plot V with basemap:
    fig = plt.figure()
    bm = Mplt.start_HYCOM_map('TP4')

    contours = []
    if not np.isnan(Bc):
        # binary of ice:
        B = getbin(V)

        # contours with skimage:
        # skimage info: http://scikit-image.org/docs/dev/auto_examples/plot_contours.html
        from skimage import measure
        contours = measure.find_contours(B, Bc)

    if 1:
        # plot conc
        bm.pcolor(plon, plat, V, vmin=Vmin, vmax=Vmax, latlon=True)
        bm.colorbar()
Ejemplo n.º 7
0
               # print(i,j,ii-1,jj-1,vv)

            # else:
            #    print('\nWARNING! '+var_name+' is masked var at:')
            #    print('Data grid:')
            #    print(ii,jj)
            #    print(dlon[jj-1,ii-1],dlat[jj-1,ii-1])
            #    print('Model grid')
            #    print(i,j)
            #    print(plon[i,j],plat[i,j])
            #    print('\n')
   ###############################################################################################

   ###############################################################################################
   # plot interpolated variable
   bmap  = Fplt.start_HYCOM_map(MOD)
   Vi    = np.ma.array(vinterp,mask=np.isnan(vinterp))
   Vmin  = Vi.min()
   Vmax  = Vi.max()
   cmap  = cm.jet
   cmap.set_bad(color='w')

   print('Plotting interpolated variable')
   print('Range in '+var_name+':')
   print(Vmin,Vmax)
   fig2  = plt.figure()
   ax2   = fig2.add_subplot(1,1,1)
   PC    = bmap.pcolor(plon,plat,Vi,ax=ax2,latlon=True,\
                        vmin=Vmin,vmax=Vmax)
   fig2.colorbar(PC)
   Fplt.finish_map(bmap,ax=ax2)