@@ 273-320 (lines=48) @@ | ||
270 | ||
271 | return qlat, qlon |
|
272 | ||
273 | def _qd2apex_nonvectorized(self, qlat, qlon, height): |
|
274 | """Converts quasi-dipole to modified apex coordinates. |
|
275 | ||
276 | Parameters |
|
277 | ---------- |
|
278 | qlat : float |
|
279 | Quasi-dipole latitude |
|
280 | qlon : float |
|
281 | Quasi-dipole longitude |
|
282 | height : float |
|
283 | Altitude in km |
|
284 | ||
285 | Returns |
|
286 | ------- |
|
287 | alat : float |
|
288 | Modified apex latitude |
|
289 | alon : float |
|
290 | Modified apex longitude |
|
291 | ||
292 | Raises |
|
293 | ------ |
|
294 | ApexHeightError |
|
295 | if apex height < reference height |
|
296 | ||
297 | """ |
|
298 | # Evaluate the latitude |
|
299 | qlat = helpers.checklat(qlat, name='qlat') |
|
300 | ||
301 | # Get the longitude and apex height |
|
302 | alon = qlon |
|
303 | h_apex = self.get_apex(qlat, height) |
|
304 | ||
305 | if h_apex < self.refh: |
|
306 | if np.isclose(h_apex, self.refh, rtol=0, atol=1e-5): |
|
307 | # Allow for values that are close |
|
308 | h_apex = self.refh |
|
309 | else: |
|
310 | estr = ''.join(['apex height ({:.3g}) is < '.format(h_apex), |
|
311 | 'reference height ({:.3g})'.format(self.refh), |
|
312 | ' for qlat {:.3g}'.format(qlat)]) |
|
313 | raise ApexHeightError(estr) |
|
314 | ||
315 | # Convert the latitude |
|
316 | sqlat = np.sign(qlat) if qlat != 0 else 1 |
|
317 | alat = sqlat * np.degrees(np.arccos(np.sqrt((self.RE + self.refh) |
|
318 | / (self.RE + h_apex)))) |
|
319 | ||
320 | return alat, alon |
|
321 | ||
322 | def _map_EV_to_height(self, alat, alon, height, newheight, data, ev_flag): |
|
323 | """Maps electric field related values to a desired height |
|
@@ 227-271 (lines=45) @@ | ||
224 | # ------------------------- |
|
225 | # Define the hidden methods |
|
226 | ||
227 | def _apex2qd_nonvectorized(self, alat, alon, height): |
|
228 | """Convert from apex to quasi-dipole (not-vectorised) |
|
229 | ||
230 | Parameters |
|
231 | ----------- |
|
232 | alat : (float) |
|
233 | Apex latitude in degrees |
|
234 | alon : (float) |
|
235 | Apex longitude in degrees |
|
236 | height : (float) |
|
237 | Height in km |
|
238 | ||
239 | Returns |
|
240 | --------- |
|
241 | qlat : (float) |
|
242 | Quasi-dipole latitude in degrees |
|
243 | qlon : (float) |
|
244 | Quasi-diplole longitude in degrees |
|
245 | ||
246 | """ |
|
247 | # Evaluate the latitude |
|
248 | alat = helpers.checklat(alat, name='alat') |
|
249 | ||
250 | # Convert modified apex to quasi-dipole, longitude is the same |
|
251 | qlon = alon |
|
252 | ||
253 | # Get the apex height |
|
254 | h_apex = self.get_apex(alat) |
|
255 | ||
256 | if h_apex < height: |
|
257 | if np.isclose(h_apex, height, rtol=0, atol=1e-5): |
|
258 | # Allow for values that are close |
|
259 | h_apex = height |
|
260 | else: |
|
261 | estr = ''.join(['height {:.3g} is > '.format(np.max(height)), |
|
262 | 'apex height {:.3g} for alat {:.3g}'.format( |
|
263 | h_apex, alat)]) |
|
264 | raise ApexHeightError(estr) |
|
265 | ||
266 | # Convert the latitude |
|
267 | salat = np.sign(alat) if alat != 0 else 1 |
|
268 | qlat = salat * np.degrees(np.arccos(np.sqrt((self.RE + height) |
|
269 | / (self.RE + h_apex)))) |
|
270 | ||
271 | return qlat, qlon |
|
272 | ||
273 | def _qd2apex_nonvectorized(self, qlat, qlon, height): |
|
274 | """Converts quasi-dipole to modified apex coordinates. |