Extracting the value from Netcdf file with longitude and lattitude

I

Isaac Won

Hi,
My question may be confusing.

Now I would like to extract temperature values from model output with python.

My model output have separate temperature, longitude and latitude variables.

So, I overlap these three grid variables on one figure to show temperature with longitude and latitude through model domain.

Up to this point, everything is fine. The problem is to extract temperature value at certain longitude and latitude.

Temperature variable doesn't have coordinate, but only values with grid.

Do you have idea about this issue?

Below is my code for the 2 D plot with temperature on model domain.

varn1 = 'T2'
varn2 = 'XLONG'
varn3 = 'XLAT'
Temp = read_netcdf(filin,varn1)
Lon = read_netcdf(filin,varn2)
Lat = read_netcdf(filin,varn3)

Temp_plt = Temp[12,:,:]
Lon_plt = Lon[12,:,:]
Lat_plt = Lat[12,:,:]
x = Lon_plt
y = Lat_plt

Temp_c = Temp_plt-273.15
myPLT = plt.pcolor(x,y,Temp_c)
mxlabel = plt.xlabel('Latitude')
mylabel = plt.ylabel('Longitude')
plt.xlim(126.35,127.35)
plt.ylim(37.16,37.84)
myBAR = plt.colorbar(myPLT)
myBAR.set_label('Temperature ($^\circ$C)')
plt.show()

--------------------------------------------------
read_netcdf is a code for extracting values of [time, x,y] format.

I think that the point is to bind x, y in Temp_plt with x, y in Lon_plt and Lat_plt to extract temperature values with longitude and latitude input.

This question might be confusing. If you can't understand please let me know.

Any idea or help will be really appreciated.

Best regards,

Hoonill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top