#73 Add LITHO1 model to Rockhound

Open Agustina Pesce aguspesce

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 4 files from the diff.
Newly tracked file
rockhound/litho1.py created.
Other files ignored by Codecov

@@ -0,0 +1,232 @@
Loading
1 +
"""
2 +
Fetch and load the LITHO1.0 model
3 +
"""
4 +
import os
5 +
import xarray as xr
6 +
from pooch import Untar
7 +
import pandas as pd
8 +
import numpy as np
9 +
10 +
from .registry import REGISTRY
11 +
12 +
13 +
COORDINATES_FILE = "Icosahedron_Level7_LatLon_mod.txt"
14 +
PROPERTIES = ["depth", "density", "Vp", "Vs", "Qkappa", "Qmu", "Vp2", "Vs2", "eta"]
15 +
COL_NAMES = PROPERTIES + ["boundaries"]
16 +
BOUNDARIES = [
17 +
    "IC0",
18 +
    "IC1",
19 +
    "IC2",
20 +
    "IC3",
21 +
    "IC4",
22 +
    "IC5",
23 +
    "IC6",
24 +
    "IC7",
25 +
    "IC8",
26 +
    "IC9",
27 +
    "IC10",
28 +
    "IC11",
29 +
    "IC12",
30 +
    "IC13",
31 +
    "IC14",
32 +
    "IC15",
33 +
    "IC16",
34 +
    "IC17",
35 +
    "IC18",
36 +
    "IC19",
37 +
    "IC20",
38 +
    "IC21",
39 +
    "IC22",
40 +
    "IC23",
41 +
    "IC24",
42 +
    "OC0",
43 +
    "OC1",
44 +
    "OC2",
45 +
    "OC3",
46 +
    "OC4",
47 +
    "OC5",
48 +
    "OC6",
49 +
    "OC7",
50 +
    "OC8",
51 +
    "OC9",
52 +
    "OC10",
53 +
    "OC11",
54 +
    "OC12",
55 +
    "OC13",
56 +
    "OC14",
57 +
    "OC15",
58 +
    "OC16",
59 +
    "OC17",
60 +
    "OC18",
61 +
    "OC19",
62 +
    "OC20",
63 +
    "OC21",
64 +
    "OC22",
65 +
    "OC23",
66 +
    "OC24",
67 +
    "OC25",
68 +
    "OC26",
69 +
    "OC27",
70 +
    "OC28",
71 +
    "OC29",
72 +
    "OC30",
73 +
    "OC31",
74 +
    "OC32",
75 +
    "OC33",
76 +
    "OC34",
77 +
    "OC35",
78 +
    "OC36",
79 +
    "OC37",
80 +
    "OC38",
81 +
    "OC39",
82 +
    "OC40",
83 +
    "OC41",
84 +
    "OC42",
85 +
    "OC43",
86 +
    "OC44",
87 +
    "OC45",
88 +
    "M0",
89 +
    "M1",
90 +
    "M2",
91 +
    "M3",
92 +
    "M4",
93 +
    "M5",
94 +
    "M6",
95 +
    "M7",
96 +
    "M8",
97 +
    "M9",
98 +
    "M10",
99 +
    "M11",
100 +
    "M12",
101 +
    "M13",
102 +
    "M14",
103 +
    "M15",
104 +
    "M16",
105 +
    "M17",
106 +
    "M18",
107 +
    "M19",
108 +
    "M20",
109 +
    "M21",
110 +
    "M22",
111 +
    "M23",
112 +
    "M24",
113 +
    "M25",
114 +
    "M26",
115 +
    "M27",
116 +
    "M28",
117 +
    "M29",
118 +
    "M30",
119 +
    "M31",
120 +
    "M32",
121 +
    "M33",
122 +
    "M34",
123 +
    "M35",
124 +
    "M36",
125 +
    "M37",
126 +
    "M38",
127 +
    "M39",
128 +
    "M40",
129 +
    "M41",
130 +
    "M42",
131 +
    "M43",
132 +
    "M44",
133 +
    "M45",
134 +
    "M46",
135 +
    "M47",
136 +
    "M48",
137 +
    "M49",
138 +
    "M50",
139 +
    "M51",
140 +
    "M52",
141 +
    "M53",
142 +
    "M54",
143 +
    "M55",
144 +
    "M56",
145 +
    "M57",
146 +
    "M58",
147 +
    "M59",
148 +
    "M60",
149 +
    "M61",
150 +
    "M62",
151 +
    "M63",
152 +
    "M64",
153 +
    "M65",
154 +
    "M66",
155 +
    "M67",
156 +
    "M68",
157 +
    "M69",
158 +
    "M70",
159 +
    "M71",
160 +
    "A-BOTTOM",
161 +
    "A-TOP",
162 +
    "ASTHENO-BOTTOM",
163 +
    "ASTHENO-TOP",
164 +
    "LID-BOTTOM",
165 +
    "LID-TOP",
166 +
    "CRUST3-BOTTOM",
167 +
    "CRUST3-TOP",
168 +
    "CRUST2-BOTTOM",
169 +
    "CRUST2-TOP",
170 +
    "CRUST1-BOTTOM",
171 +
    "CRUST1-TOP",
172 +
    "SEDS3-BOTTOM",
173 +
    "SEDS3-TOP",
174 +
    "SEDS2-BOTTOM",
175 +
    "SEDS2-TOP",
176 +
    "SEDS1-BOTTOM",
177 +
    "SEDS1-TOP",
178 +
    "ICE-BOTTOM",
179 +
    "ICE-TOP",
180 +
    "WATER-BOTTOM",
181 +
    "WATER-TOP",
182 +
]
183 +
184 +
185 +
def fetch_litho1(*, load=True):
186 +
    """
187 +
    Load the LITHO1 model.
188 +
189 +
    LITHO1.0 model is a 1$^o$ tessellated model of the crust and uppermost
190 +
    mantle of the Earth, extending into the upper mantle to include the
191 +
    lithospheric lid and underlying asthenosphere.
192 +
    The model is parameterized laterally by tessellated nodes and vertically
193 +
    as a series of geophysically identified layers, such as water, ice,
194 +
    sediments, crystalline crust, lithospheric lid, and asthenosphere.
195 +
    More details can be found in the model webside
196 +
    https://igppweb.ucsd.edu/~gabi/litho1.0.html and [PASYANOS]_.
197 +
    """
198 +
    fnames = REGISTRY.fetch("litho1.0.tar.gz", processor=Untar())
199 +
    if not load:
200 +
        return fnames
201 +
202 +
    # Load the space coordinates
203 +
    (coord_file,) = tuple(i for i in fnames if i.endswith(COORDINATES_FILE))
204 +
    latitude, _, longitude = np.loadtxt(coord_file, unpack=True)
205 +
    # Create array of nodes indices (nodes indices start on 1)
206 +
    nodes = np.arange(1, latitude.size + 1)
207 +
    # Initialize xr.Dataset
208 +
    coords = {
209 +
        "nodes": ("nodes", nodes),
210 +
        "longitude": ("nodes", longitude),
211 +
        "latitude": ("nodes", latitude),
212 +
        "boundaries": ("boundaries", BOUNDARIES),
213 +
    }
214 +
    arrays = {
215 +
        i: (["nodes", "boundaries"], np.nan * np.ones((nodes.size, len(BOUNDARIES))))
216 +
        for i in PROPERTIES
217 +
    }
218 +
    dataset = xr.Dataset(arrays, coords=coords)
219 +
    # Read node files
220 +
    for node in nodes:
221 +
        (node_file,) = tuple(
222 +
            i for i in fnames if os.path.basename(i) == "node{}.model".format(node)
223 +
        )
224 +
        node_df = pd.read_csv(
225 +
            node_file, sep=r"\s+", skiprows=1, names=COL_NAMES, index_col=-1
226 +
        )
227 +
        # Remove duplicate rows in the dataframe
228 +
        node_df = node_df.drop_duplicates()
229 +
        # Remplace the dataframe information in the dataset
230 +
        for b, p in zip(node_df.index, PROPERTIES):
231 +
            dataset[p].loc[dict(nodes=node, boundaries=b)] = node_df[p].loc[b]
232 +
    return dataset

Learn more Showing 1 files with coverage changes found.

New file rockhound/litho1.py
New
Loading file...
Files Coverage
rockhound -10.60% 89.40%
Project Totals (8 files) 89.40%
Loading