Skip to content

Instantly share code, notes, and snippets.

import sys
import numpy as np
from netCDF4 import Dataset
# ......................................................................
# STEP 1
# read .grd file and take coordinates of grid points
# ......................................................................
# print grid
from netCDF4 import Dataset as dt
import numpy as np
fileID = 'dat_3.nc'
ncfile = dt(fileID, 'r')
# print(ncfile.variables)
# np array -> int16 u10(time, latitude, longitude)
lat = np.array(ncfile.variables['latitude'][:], dtype=np.float32) # x
long = np.array(ncfile.variables['longitude'][:], dtype=np.float32) # y
!Model of migration of krill in Scotia sea (date 2000)
!The first approximation
!Pleshanov D. A. 05.2015
program Migrationofkrillmodel
use ifport
implicit none
integer nDay,ix,jy,kz,i1,n1,nt,i,j,iday,k,iitime,zz
integer ix1,ix2,jy1,jy2,kz1,kz2
@m1t9
m1t9 / read_nc.md
Last active March 30, 2017 13:03
This script reads netCDF files. NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.

READ NETCDF FILES

This script reads netCDF files. NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.

from netCDF4 import Dataset
import numpy as np
import sys

print('\nStart...\n')

create U- V- wind and pressure files for space varying distribution data

import sys
import numpy as np
from netCDF4 import Dataset

print('\nstart read .nc file\n')

# sys.stdout.write('-'+key+' ')
import numpy as np
from netCDF4 import Dataset
import sys
# create .grd file
xpc = 31.0
ypc = 71.0
xlenc = 18
ylenc = 9
#
# m1t9 29-01-2018
#
# DISTRIBUTION VELOCITY ANGLES TO RUMBS
# INPUT FILE STRUCTURE CONTAIN ONE COLOMN OF ANGLES
#
import numpy as np
import sys
#
# m1t9 23-10-2017
#
# PRINT COORDINATES OF GRID POINTS GENERATED FROM DELTARES RGRFGRID TO DATA FILE THAT
# CONTAIN TWO COLOMNS OF LATITUDE AND LONGITUDE
#
# INPUT: GRID FILE (.GRD) CREATED BY USING DELTARES RGRFGRID
# SEE MORE INFORMATION IN DELFT3D DOCUMENTATION OR .GRD SAMPLE
#
#
# m1t9 06-09-2017
#
# AVIABLE FUNCTIONS:
# DISPLAY INFORMATION ABOUT INPUT NETCDF FILE AND AVIABLE DATA
# READ DATA FROM NC FILE USING NETCDF4 PYTHON LIBRARY
# CREATE INPUT FILES OF METEOROLOGICAL (OPTIONALY) DATA FOR DELTARES DELFT3D MODEL IN PROPER FORMAT
#
# AVIABLE METEO FILES DATA UNITS:
# AIR TEMPERATURE (2 METER UNDER WATER SURFACE) (.AMT)

Create meteorological input files from netCDF for hydrometeorological 3d model Delft3d by Deltares

AVIABLE FUNCTIONS: DISPLAY INFORMATION ABOUT INPUT NETCDF FILE AND AVIABLE DATA READ DATA FROM NC FILE USING NETCDF4 PYTHON LIBRARY CREATE INPUT FILES OF METEOROLOGICAL (OPTIONALY) DATA FOR DELTARES DELFT3D MODEL IN PROPER FORMAT

AVIABLE METEO FILES DATA UNITS: AIR TEMPERATURE (2 METER UNDER WATER SURFACE) (.AMT)