Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use original ETOPO1 heights and cast ints to float #32

Merged
merged 2 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use original ETOPO1 heights and cast ints to float
ETOPO1 is referenced to sea level. I had used a geoid model to convert
it to geometric heights but this is not a great idea. Revert back to the
original. The data were stored as ints to save space but this can cause
problems with divisions and other operations. Cast them back to float
after loading with our functions.

Fixes #29
Fixes #30
  • Loading branch information
leouieda committed Dec 13, 2018
commit a54520d04bfd2b777ea5d07c78bbb9fb8a97a1c9
10 changes: 4 additions & 6 deletions data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ These files are used as sample data in Harmonica:
geometric (ellipsoidal) height of 10 km. The grid was generated from the EIGEN-6C4
gravity field model using the [ICGEM Calculation Service](http:https://icgem.gfz-potsdam.de)
and the WGS84 Reference System. The data are stored in a netCDF file and then `xz`
compressed using Python's `lzma` library.
compressed.
* `etopo1-0.5deg.nc.xz`: Global relief (topography and bathymetry) of the Earth based on
the ETOPO1 model at 0.5 degree grid spacing. The original heights referenced to the
sea level were converted to geometric (ellipsoidal) heights using a geoid grid derived
from the EIGEN-6C4 gravity field model. Both grids were generated by the
[ICGEM Calculation Service](http:https://icgem.gfz-potsdam.de). The data are stored in a
netCDF file and then `xz` compressed using Python's `lzma` library.
the ETOPO1 model at 0.5 degree grid spacing. The grid was generated by the [ICGEM
Calculation Service](http:https://icgem.gfz-potsdam.de). The data are stored in a netCDF
file and then `xz` compressed.
* `rio-magnetic.csv.xz`: Total-field magnetic anomaly data from the northwestern part of
an airborne survey of Rio de Janeiro, Brazil, conducted in 1978. Columns are
longitude, latitude, total field anomaly (nanoTesla), observation height above the
Expand Down
Binary file modified data/etopo1-0.5deg.nc.xz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
Gravity of the Earth
====================
Earth Gravity
=============

This is the magnitude of the gravity vector of the Earth (gravitational + centrifugal)
at 10 km height. The data is on a regular grid with 0.5 degree spacing which was
generated from the spherical harmonic model EIGEN-6C4 [Forste_etal2014]_.
at 10 km height. The data is on a regular grid with 0.5 degree spacing at 10km
ellipsoidal height. It was generated from the spherical harmonic model EIGEN-6C4
[Forste_etal2014]_.
"""
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
Topography of the Earth
=======================
Earth Topography
================

The topography and bathymetry of the Earth according to the ETOPO1 model
[AmanteEakins2009]_. The original model has 1 arc-minute grid spacing but here we
downsampled to 0.5 degree grid spacing to save space and download times.
downsampled to 0.5 degree grid spacing to save space and download times. Heights are
referenced to sea level.
"""
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
Expand Down
2 changes: 1 addition & 1 deletion harmonica/datasets/registry.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
etopo1-0.5deg.nc.xz 9f21f7c946e649389dce28631de94fa05217750e9ebc77df4311458c33f0682b
etopo1-0.5deg.nc.xz d975b2f90111043744f70eb1382ed4c654c79065cabe71d067ea8fde7010be2b
gravity-earth-0.5deg.nc.xz 02c62a251225e2e76722a80d87c488160fbdcae2c1a8bbc2386c32e68ea8f43a
rio-magnetic.csv.xz 134542c1a0c4b89040a4b7d0e52ff55b97e4a3fb7cbda7004a739166897a5eeb
12 changes: 9 additions & 3 deletions harmonica/datasets/sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def fetch_gravity_earth():

"""
fname = POOCH.fetch("gravity-earth-0.5deg.nc.xz")
data = _load_xz_compressed_grid(fname, engine="scipy")
# The heights are stored as ints and data as float32 to save space on the data file.
# Cast them to float64 to avoid integer division errors.
data = _load_xz_compressed_grid(fname, engine="scipy").astype("float64")
return data


Expand All @@ -56,9 +58,11 @@ def fetch_topography_earth():
arc-minute grid spacing but here we downsampled to 0.5 degree grid spacing to save
space and download times. The downsampled grid was generated from a spherical
harmonic model using the `ICGEM Calculation Service
<http:https://icgem.gfz-potsdam.de/>`__. See the ``attrs`` attribute of the
<http:https://icgem.gfz-potsdam.de/>`__. See the ``attrs`` attribute of the returned
:class:`xarray.Dataset` for information regarding the grid generation.

ETOPO1 heights are referenced to "sea level".

If the file isn't already in your data directory, it will be downloaded
automatically.

Expand All @@ -69,7 +73,9 @@ def fetch_topography_earth():

"""
fname = POOCH.fetch("etopo1-0.5deg.nc.xz")
data = _load_xz_compressed_grid(fname, engine="scipy")
# The data are stored as int16 to save disk space. Cast them to floats to avoid
# integer division problems when processing.
data = _load_xz_compressed_grid(fname, engine="scipy").astype("float64")
return data


Expand Down