Read data with python / netCDF> nc.variables [] / Check data size

Operating environment


CentOS 6.5

We plan to compare the numbers in multiple NetCDF files. Floating-point values can change slightly due to different environments. I want to display it as a graph.

I found an example of reading netCDF4 with python. Reference 1 http://qiita.com/okadate/items/954574a95545b06ca257 Reference 2 http://qiita.com/AnchorBlues/items/2dd18c1e9587c8f495bc

I implemented the following. It seems that you can see the size of the data read by .shape.

read_nc.py


import netCDF4

nc = netCDF4.Dataset('sample.nc', 'r')
dim_we = len(nc.dimensions['west_east'])
dim_sn = len(nc.dimensions['south_north'])

data = nc.variables['CONC'][:]
nc.close()

print data.shape

print 'dim_we=',dim_we
print 'dim_sn=',dim_sn

result


$ python read_nc.py 
(24, 1, 1, 3, 65, 82)
dim_we= 82
dim_sn= 65

24: Dimension of time 3: top, bottom 65: south north 82: west east

The remaining 1,1 are undigested.

Recommended Posts

Read data with python / netCDF> nc.variables [] / Check data size
Read json data with python
[python] Read data
[Python] Read a csv file with a large data size using a generator
Data analysis with python 2
Read Python csv data with Pandas ⇒ Graph with Matplotlib
Read table data in PDF file with Python
Domain check with Python
Data analysis with Python
Check version with python
Summary of how to read numerical data with python [CSV, NetCDF, Fortran binary]
Sample data created with python
Read csv with python pandas
Check python coverage with pytest-cov
Draw netCDF file with python
Get Youtube data with python
Read Protocol Buffers data in Python3
Handle NetCDF format data in Python
[Python] Get economic data with DataReader
Python data structures learned with chemoinformatics
[python] Read information with Redmine API
Reading and writing NetCDF with Python
Multi-line size specification reading with python
Read files in parallel with Python
Easy data visualization with Python seaborn.
Process Pubmed .xml data with python
Data analysis starting with python (data visualization 1)
Read fbx from python with cinema4d
Data analysis starting with python (data visualization 2)
Python application: Data cleansing # 2: Data cleansing with DataFrame
Get additional data in LDAP with python
Data pipeline construction with Python and Luigi
Receive textual data from mysql with python
[Note] Get data from PostgreSQL with Python
[Python] Easy argument type check with dataclass
Process Pubmed .xml data with python [Part 2]
Read CSV file with python (Download & parse CSV file)
Add a Python data source with Redash
Retrieving food data with Amazon API (Python)
Try working with binary data in Python
Check raw data with Kaggle's Titanic (kaggle ⑥)
Generate Japanese test data with Python faker
Check the existence of the file with python
Convert Excel data to JSON with python
[Python] Use string data with scikit-learn SVM
Download Japanese stock price data with python
[C] [python] Read with AquesTalk on Linux
Let's read the RINEX file with Python ①
Check stock prices with slackbot using python
Manipulate DynamoDB data with Lambda (Node & Python)
Convert FX 1-minute data to 5-minute data with Python
[Python] Read images with OpenCV (for beginners)
Recommendation of Altair! Data visualization with Python
Data analysis starting with python (data preprocessing-machine learning)
Let's do MySQL data manipulation with Python
Organize data divided by folder with Python
[Automation] Read a Word document with Python
Check the file size with du -sh *
Read a character data file with numpy
Python / numpy> Read the data file with the item name line> Use genfromtxt ()
How to read problem data with paiza