Closed saraemp closed 1 month ago
The code snippet below is working for me. Would you like to try it?
import gplately
from plate_model_manager import PlateModelManager, PresentDayRasterManager
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
#Initialize the raster manager and load the ETOPO1 grid data
raster_manager = PresentDayRasterManager()
etopo = gplately.grids.read_netcdf_grid(raster_manager.get_raster("ETOPO1_grd"))
#Extract the rows and columns of the etopo.data array
etopo = etopo.data[::]
#Define the latitude and longitude ranges
lat_start, lat_end = -90, 90
lon_start, lon_end = -180, 180
# Create latitude and longitude arrays
latitudes = np.linspace(lat_start, lat_end, etopo.shape[0])
longitudes = np.linspace(lon_start, lon_end, etopo.shape[1])
divnorm = matplotlib.colors.TwoSlopeNorm(vmin=-500., vcenter=0, vmax=4000)
plt.imshow(etopo, extent=[lon_start, lon_end, lat_start, lat_end], origin='lower', norm=divnorm, cmap='terrain')
here is the image I plotted with the above code snippet.
Hi Michael, yes we both ended up writing the same that code snippet. That snippet is not currently on the 06-Rasters. I wrote it because the links for the current instructions are broken. https://github.com/GPlates/gplately/blob/master/Notebooks/06-Rasters.ipynb
My point was that at the moment this is the only thing that the notebook says:
Once I figured out that this is the command I had to run gplately.grids.read_netcdf_grid(raster_manager.get_raster("ETOPO1_grd")) I got a message saying: "The local file(s) is/are still good. Will not download again at this moment."
But I wasn't sure what to do next and so that's why I am shared the code snipped I wrote so we both ended up writing the same code ;)
The message "The local file(s) is/are still good. Will not download again at this moment." means GPlately had already downloaded the raster file before and there is a copy in your local cache. So GPlately will not download it again and just use the local copy.
Alternatively, you can import a local netcdf file using by passing the filename to gplately.grids.Raster or gplately.grids.read_netcdf_grid
This means that you may use a local file directly instead of asking GPlately to download the file from Internet. For example, if you have a file on local computer and its path is "present-day-rasters/etopo1_grd/ETOPO1_Ice_g_gmt4.grd", you can just use gplately.grids.read_netcdf_grid("present-day-rasters/etopo1_grd/ETOPO1_Ice_g_gmt4.grd")
instead of gplately.grids.read_netcdf_grid(raster_manager.get_raster("ETOPO1_grd"))
It seems to me that you are doing things correctly. I don't really see a problem here.
Hi @saraemp,
I am not sure what I can do for this issue.
Do you want me to add "from plate_model_manager import PlateModelManager, PresentDayRasterManager" to code cell 7?
The import actually has been done in code cell 1. It is not necessary to import it again.
You need to run the code cells from top to bottom in order. Some code cells rely on the output of previous code cells to work.
This issue is for the following instructions:
Alternatively, you can import a local netcdf file using by passing the filename to gplately.grids.Raster or gplately.grids.read_netcdf_grid
The links are broken (404) and once you run the following to make it work gplately.grids.read_netcdf_grid(raster_manager.get_raster("ETOPO1_grd")) you get a message that says: "The local file(s) is/are still good. Will not download again at this moment."
But doesn't tell you that you have run the following
from plate_model_manager import PlateModelManager, PresentDayRasterManager
Initialize the raster manager and load the ETOPO1 grid data
raster_manager = PresentDayRasterManager() etopo = gplately.grids.read_netcdf_grid(raster_manager.get_raster("ETOPO1_grd"))
Extract the rows and columns of the etopo.data array
etopo = etopo.data[::]
Define the latitude and longitude ranges
lat_start, lat_end = -90, 90 lon_start, lon_end = -180, 180
Create latitude and longitude arrays
latitudes = np.linspace(lat_start, lat_end, etopo.shape[0])
longitudes = np.linspace(lon_start, lon_end, etopo.shape[1])
plt.imshow(etopo, extent=[lon_start, lon_end, lat_start, lat_end], origin='lower', norm=divnorm, cmap=terrain_map)