GETM Transect

33 views
Skip to first unread message

Johan Söderkvist

unread,
Oct 18, 2023, 6:35:25 AM10/18/23
to getm-...@googlegroups.com

Dear GETM users

 

I want to create a transect output file along a deep channel from Kattegat to the Baltic Sea.

I am considering to create several short transect files and then merge them together.

Is there another, less cumbersome method, to create a GETM output file that doesn’t follow a straight line?

 

best regards

JOHAN sÖDERQVIST

 

JOINT GEOMETOC SUPPORT CENTRE

DANISH MINISTRY OF DEFENCE ACQUISITION AND LOGISTICS ORGANISATION

Lautrupbjerg 1-5, DK-2750 Ballerup

Denmark


Phone: +45 4078 7321
E-mail: j...@fcoo.dk

www.fmi.dk

 

Marvin Lorenz

unread,
Oct 18, 2023, 7:36:52 AM10/18/23
to getm-...@googlegroups.com
Hi Johan,

you can use the nctransect tool from the getm-utils https://sourceforge.net/p/getm-utils/wiki/GETM%20Utils/ (src/nctransect)
In principle you need some getm output files of the Batlic Sea e.g. for salinity in (time,level,lat,lon) and a txt file with lon/lat points onto which nctransect should interpolate the data.
You can then use the command line with something like this:
nctransect -x lonc -y latc -i lonlat.txt input.nc output.nc
I hope this helps.
Best Marvin

--

---
You received this message because you are subscribed to the Google Groups "GETM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to getm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/getm-users/e40a3b2badd64dde83b39778fe9e6c33%40fcoo.dk.

Johan Söderkvist

unread,
Oct 18, 2023, 7:55:28 AM10/18/23
to getm-...@googlegroups.com

Dear Martin

 

Thank you for you input.

> In principle you need some getm output files of the Batlic Sea e.g. for salinity in (time,level,lat,lon)

It is this step that I would like to avoid; with one large file that covers the Kattegat – Baltic Sea region

 

Best regards

Johan

Marvin Lorenz

unread,
Oct 18, 2023, 8:02:01 AM10/18/23
to getm-...@googlegroups.com
Hi Johan,
I am afraid you have to bite the apple and follow the separate sections approach you described in your first email.
Best regards,
Marvin

Johan Söderkvist

unread,
Oct 18, 2023, 9:06:59 AM10/18/23
to getm-...@googlegroups.com

Dear Martin

 

Going for many station files instead, and then merge then together.

Hopefully python will help me find the deep channel

germo...@gmail.com

unread,
Oct 18, 2023, 9:09:08 AM10/18/23
to GETM-users
Hi Johan!

I have used Python's xarray to extract transects, but still utilized the "ncmerge" tool.

Basically, you need to determine the files, you need for the transect, merge only these for some tempfile and then quite straighforwardly extract with xarray along the transect points.

Regards,
Germo 

Here is just an example part from my extraction script (not going for details):

proclist = None;
# ----------------------------------------------
for dateval in dates:
    tmpfile=tmpdir+'/'+'newsigmatrans_'+koordfail+'_'+dateval+'.nc'
    if os.path.exists(tmpfile)==True: continue
    # -------------------------------------------------------------------
    if os.path.exists(datadir+'/'+dateval)==False: continue
    # -------------------------------------------------------------------
    # get proclist:
    if proclist is None:
        x0,x1,y0,y1 = np.min(modcoords[:,0]),np.max(modcoords[:,0]),np.min(modcoords[:,1]),np.max(modcoords[:,1])
        kk = np.where((loninm>(x0-2*resolution/(60*1852))) & (loninm<(x1+2*resolution/(60*1852))) & (latinm>y0-2*resolution/(60*1852)) & (latinm<y1+2*resolution/(60*1852)))
        proclist = np.unique(procmask[kk]);proclist = proclist[~np.isnan(proclist)];
    # -------------------------------------------------------------------
    if len(proclist)>1:
        fileins = [ datadir+'/'+dateval+'/'+fpref+str(int(vv)).rjust(4,'0')+'.nc' for vv in proclist]        
        filein = tmpdir + '/' + 'merged_'+dateval+'.nc'
        cstr = 'ncmerge -H '+' '.join(fileins)+' '+filein;subprocess.call(cstr,shell=True)
    else:
        filein = datadir+'/'+dateval+'/'+fpref+str(int(proclist)).rjust(4,'0')+'.nc'
    # -------------------------------------------------------------------
    dfin = xr.open_dataset(filein);
    # -------------------------------------------------------------------
    dfin = dfin.isel(level=slice(1,nlevels))
    # -------------------------------------------------------------------
    dfout = dfin.interp({
        'lonc': xr.DataArray(modcoords[:, 0], dims='dist'),
        'latc': xr.DataArray(modcoords[:, 1], dims='dist')
    }, method='linear')
    dfout.coords['dist'] = range(len(distvec))
    dfout['dist'] = xr.DataArray(distvec,dims='dist')
    dfout['lon'] = xr.DataArray(modcoords[:,0],dims='dist');
    dfout['lat'] = xr.DataArray(modcoords[:,1],dims='dist');
    dfout.to_netcdf(tmpfile)
    print('Wrote: ',tmpfile)
# =============================================


Johan Söderkvist

unread,
Oct 19, 2023, 2:39:24 AM10/19/23
to getm-...@googlegroups.com

Dear Germo

 

Thank you! I will look into it

 

Best regards

Joha

Reply all
Reply to author
Forward
0 new messages