hello, i am trying to change my bathymetric data using gebco instead od etopo2. i have change the names and data type but it is still not given. anyone having add_topo files suitable with gebco data? thanks
Hello, one possible solution you could explore involves creating a new netCDF3-classic file by taking data from GEBCO file and changing its variable names to the format used in the ETOPO2 file found in DATASETS_CROCOTOOLS/Topo. I have a Python script that I created to perform this format conversion. Although I did not ultimately use the result (I instead used a pre-existing CROCO mesh provided by a professor who also performed modeling in the same study area); However, I think you could try it and see how it goes.
from netCDF4 import data set
input_file = ‘path to gebco file’
dataset = DataSet(input_file, ‘r’)
elevation = dataset.variables[‘elevation’][:]
lat = dataset.variables[‘lat’][:]
lon = dataset.variables[‘lon’][:]
dataset.close()
output_file = ‘Output path\Output file name.nc’
new_dataset = Dataset (output_file, ‘w’, format = ‘NETCDF3_CLASSIC’)
new_dataset.createDimension(‘latitude’, len(latitude))
new_dataset.createDimension(‘lon’, len(lon))
new_lat = new_dataset.createVariable(‘lat’, ‘f4’, (‘lat’,))
new_lon = new_dataset.createVariable(‘lon’, ‘f4’, (‘lon’,))
new_topo = new_dataset.createVariable(‘topo’, ‘f4’, (‘lat’, ‘lon’))
new_lat[:] = latitude
new_lon[:] = long
new_topo[:, :] = elevation
new_dataset.close()
add_topo.m (3.4 KB)
Use this add_topo.m file
key word topo is need to replace with gebco varaible(“elevation”)