## Extracting temperature

### Extracting temperature

Hi all.

I am totally new with ROMs.I need to extract temp for a specific location with lat and lon coordinate.I checked the nc file output,however the dimension for temp was XI×eta*s_rho_ocean_time.Would you please how I can extract the data?

Thank you

I am totally new with ROMs.I need to extract temp for a specific location with lat and lon coordinate.I checked the nc file output,however the dimension for temp was XI×eta*s_rho_ocean_time.Would you please how I can extract the data?

Thank you

### Re: Extracting temperature

If you only have a few such location from which you want to extract fields, the easiest thing is to ask ROMS for a STATIONS file. You provide the lat,lon in the stations input file. If you don't have a chance to rerun the model, you will have to build tools for extracting from the ROMS output, using Matlab, Python, NCL, Ferret,...

### Re: Extracting temperature

I have the nc file output of ROMs from NOAA Operational Model in the Gulf of Maine. I just need to extract 20 locations from the output. The problem is I have latitude and longitude positions and the temperature dimension in the nc file is different. How I can relate lat and lon to XI and eta?

### Re: Extracting temperature

There should be a grid file somewhere with lat and lon as a function of xi and eta. The algorithm for finding the xi, eta (or i,j) of a given lat, lon is implemented inside ROMS in the routine hindices inside interpolate.F.

### Re: Extracting temperature

I extracted the closest location to my desired latitude and longitude from the 'lon_rho' and 'lat_rho' with the dimension of (xi_rho,eta_rho),in my case the dimensions are as follow: lon_rho(119*119), lat_rho(119*119), and temp(119*119*30*24) and the closest longitude index is 3304 and the correspondent subscribe in lon_rho is (91*28). Could I use this subscribe(91*28) in the 'temp' parameter to extract my desired location temperature?

### Re: Extracting temperature

I think you are saying that the index is xi=91, eta=28. Yes, you can extract the temperature at that location to get a vertical column of numbers for each time.

### Re: Extracting temperature

yes. This is the index. I will do that.

Does the grid file comes with the NC output?

Thank you

Does the grid file comes with the NC output?

Thank you

### Re: Extracting temperature

The ROMS default is to write out the grid file into every output netcdf file. I make many, many output netcdf files and have told ROMS not to put the grid into any of them. I know the grid because it is one of the ROMS input files. If you are using someone else's model output, you have to ask them for the grid if it isn't in all the output files.

### Re: Extracting temperature

Thank you so much Kate, for your reply.

### Re: Extracting temperature

Hi Kate.

I use this Matlab code to find the nearest node to my location. After using the i, j indices in the lat_rho and lon_rho, it gives me a location very far from my desired location. Could you help me with this?

Thank you.

yi =43.89818240;

xi =-66.31989730;

dist = sqrt( (lat_rho-yi)^2 +(lon_rho-xi)^2);

%dist = abs(lat_rho-yi) + abs(lon_rho-xi);

[i,j]= find(dist ==min(dist(:)));

lat_clos = lat_rho(i,j)

lon_clos = lon_rho(i,j)

I use this Matlab code to find the nearest node to my location. After using the i, j indices in the lat_rho and lon_rho, it gives me a location very far from my desired location. Could you help me with this?

Thank you.

yi =43.89818240;

xi =-66.31989730;

dist = sqrt( (lat_rho-yi)^2 +(lon_rho-xi)^2);

%dist = abs(lat_rho-yi) + abs(lon_rho-xi);

[i,j]= find(dist ==min(dist(:)));

lat_clos = lat_rho(i,j)

lon_clos = lon_rho(i,j)