Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

netcdf in python

# To extract coordinates values from a datatable using xarray

import xarray as xr
import numpy as np
import pandas as pd

# This sectin creates a dummy data
years=range(1982,1986)
time = pd.date_range('14/1/' + str(years_arr[0]) + ' 12:00:00', periods=len(years_arr), freq=pd.DateOffset(years=1))
lon = range(20,24)
lat = range(10,14)
arr1 = xr.DataArray(data, coords=[time, lat, lon], dims=['time', 'latitude', 'longitude'])

# This section performs the extraction
# extract coordinate value of the lon
arr1.coords['lon'] 			# gives you longitude as a xarray.DataArray, and
arr1.coords['lon'].values 	# gives you the values as a numpy array.

# extract all coordinates (time, lat, lon) values
time, lat, lon = arr1.indexes.values()
Comment

PREVIOUS NEXT
Code Example
Python :: percent in pandas 
Python :: turtle graphics documentation|pensize 
Python :: how to drop duplicate columns in pandas that dont have the same name? 
Python :: axios django post 
Python :: pandas to python datetime 
Python :: freecodecamp python 
Python :: handwritten digits data set 
Python :: python beautifulsoup get option tag value 
Python :: python multiple conditions in dataframe column values 
Python :: flask run 
Python :: oops concept in python 
Python :: <IPython.core.display.HTML object 
Python :: The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now 
Python :: csv read python 
Python :: soustraire deux listes python 
Python :: find highest value in array python 
Python :: python factor number 
Python :: how to find length of list python 
Python :: statsmodels 
Python :: discord bot python example 
Python :: python spawn process 
Python :: .items() python 
Python :: pandas series 
Python :: method get first last name python 
Python :: py function 
Python :: brute force string matching algorithm in python 
Python :: how to make lowercase text in python 
Python :: python in stack implementation 
Python :: quantile-quantile plot python 
Python :: installing intel python 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =