Draw netCDF file with python

Draw netCDF file with python

read_netCDF.py


import matplotlib as mp
import numpy as np

ind='hoge.grd'
Dat = np.netcdf(ind,'r').variables['z'][::-1]
lon=np.netcdf(ind,'r').variables['x'][::-1]
lat=np.netcdf(ind,'r').variables['y'][::-1]
NX, NY=np.meshgrid(lon, lat)

#The center of the color bar while specifying the minimum and maximum values of the color bar(z=0)The color of is maintained.
norm = mp.colors.TwoSlopeNorm(vcenter=0.0, vmin=-0.2, vmax=0.1)
#Cut out a part of 2D data[pixel]
extX0=950
extX1=1600
extY0=1100
extY1=1750

#Also specify figure size
fig=plt.figure(figsize=(10,10))
#jet colormap
plt.pcolormesh(NX[extY0:extY1, extX0:extX1], NY[extY0:extY1, extX0:extX1], Dat[extY0:extY1, extX0:extX1], cmap='jet', norm=norm) 
plt.colorbar() #Color bar display
plt.xlabel('Longitude [deg.]')
plt.ylabel('Latitude [deg.]')
plt.show()

A figure like this is displayed ↓ image.png

Recommended Posts

Draw netCDF file with python
Download csv file with python
Extract the xz file with python
[Python] Write to csv file with Python
[Automation with python! ] Part 1: Setting file
Implemented file download with Python + Bottle
Output to csv file with Python
Create an Excel file with Python3
Reading and writing NetCDF with Python
Draw Koch curve with Python Turtle
[Automation with python! ] Part 2: File operation
Draw an illustration with Python + OpenCV
Draw Lyapunov Fractal with Python, matplotlib
Draw arrows (vectors) with opencv / python
Script python file
FizzBuzz with Python3
Scraping with Python
Exclusive control with lock file in Python
Statistics with python
Read CSV file with python (Download & parse CSV file)
Scraping with Python
Python with Go
Check the existence of the file with python
Draw Nozomi Sasaki in Excel with python
Quickly create an excel file with Python #python
Twilio with Python
Integrate with Python
Play with 2016-Python
Python file processing
AES256 with python
Let's read the RINEX file with Python ①
Tested with Python
python starts with ()
with syntax (Python)
Create Excel file with Python + similarity matrix
Bingo with python
Record with Python → Save file (sounddevice + wave)
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
I made a configuration file with Python
[Automation] Read mail (msg file) with Python
Cast with python
nginxparser: Try parsing nginx config file with Python
How to read a CSV file with Python 2/3
Read data with python / netCDF> nc.variables [] / Check data size
[Python] Draw a directed graph with Dash Cytoscape
Try to draw a life curve with python
[Python] How to draw multiple graphs with Matplotlib
[Python] How to read excel file with pandas
Convert svg file to png / ico with Python
Read table data in PDF file with Python
[Python] Draw a Mickey Mouse with Turtle [Beginner]
Develop Windows apps with Python 3 + Tkinter (exe file)
[Python] Summary of S3 file operations with boto3
Draw a graph with matplotlib from a csv file
Extract zip with Python (Japanese file name support)
Create a Photoshop format file (.psd) with python
Convert the character code of the file with Python3
Wav file generation from numeric text with python
Read line by line from a file with Python