Skip to content

Instantly share code, notes, and snippets.

View nmathewa's full-sized avatar
🎯
Focusing

nmathewa

🎯
Focusing
  • Florida Institute of Technology
  • Melbourne, FL , USA
  • 19:27 (UTC -04:00)
View GitHub Profile
@nmathewa
nmathewa / subset.jl
Created March 1, 2022 07:30
julia subset data
using NCDataFrame
using NCDatasets
using Pkg
Pkg.add("IntervalSets")
using IntervalSets
using PlotlyJS
ds = NCDataset("ECMWF_ERA-40_subset.nc","r")
@nmathewa
nmathewa / read_net.jl
Created February 11, 2022 01:48
reading netcdf files (Julia)
using NCDataFrame
using NCDatasets
using PlotlyJS
using Pkg
using Statistics
using NaNStatistics
import NaNStatistics ; na=NaNStatistics
ds = NCDataset("ECMWF_ERA-40_subset.nc","r")
@nmathewa
nmathewa / create.jl
Created January 5, 2022 07:17
create netcdf using julia
# Importing libraries
using NCDataFrame
using NCDatasets
# create an dnetcdf dataset
dset = NCDataset("test.nc","c")
# Writing attributes
dset.attrib["Author"] = "Julia NCdataset"
@nmathewa
nmathewa / reg_sci.py
Last active June 14, 2021 09:37
scipy spatial regridding
from scipy.interpolate import griddata
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
file = "your_ncfile.nc"
dset = xr.open_dataset(file)
@nmathewa
nmathewa / cart_nc.py
Last active May 28, 2021 16:58
cartopy spatial map netcdf4
"""
Created on Fri May 28 21:15:01 2021
@author: mathew
"""
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
@nmathewa
nmathewa / nc_np_sub.py
Last active May 24, 2021 14:12
Netcdf pytfon subset using numpy
import numpy as np
from netCDF4 import Dataset
nc = "your_file.nc"
dset = Dataset(nc)
lats = dset.variables["lat"][:]
lons = dset.variables["lon"][:]
@nmathewa
nmathewa / xr_nc.py
Created May 19, 2021 12:44
netcdf using xarray
"""
Created on Wed May 19 17:55:14 2021
@author: mathew
"""
import xarray as xr
import numpy as np
@nmathewa
nmathewa / sci_net_create.py
Last active April 19, 2021 12:50
scipy_netcdf_create
from scipy.io import netcdf as nc
import numpy as np
#creatin an sample fil
net = nc.netcdf_file("test.nc",'w')
#making an attribute inside the netCDF file similarly an template can be created
net.author = "Made by NMA"
#creating dimension and its length
net.createDimension('time',10)
# setting up space for values for dimensions and variabls (name , datatype , (dims))
@nmathewa
nmathewa / gdal_resample.py
Created March 4, 2021 15:29
gdal_resample
"""
Created on Thu Mar 4 19:14:00 2021
@author: nma
"""
from osgeo import gdal
## file to be converted
in_file = "in_file.tif"
inn = gdal.Open(in_file,gdalconst.GA_ReadOnly)
@nmathewa
nmathewa / gdal_numpy_calc.py
Created March 4, 2021 15:14
gdal_numpy_calc
"""
Created on Thu Mar 4 19:14:00 2021
@author: nma
"""
from osgeo import gdal,gdal_array,gdalconst,osr
import numpy as np
raster_f = "A_raster_file.tif"
raster_s = "B_raster_file.tif"