forked from cmoestl/cme_signatures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcme_sig.py
704 lines (484 loc) · 19 KB
/
cme_sig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
#!/usr/bin/env python
# coding: utf-8
# # CME signatures
#
# cme_sig.ipynb
#
# https://github.com/cmoestl/cme_signatures
#
# for paper Möstl et al. 2021 ApJ (in prep.)
#
# Authors: C. Möstl, A. J. Weiss IWF Graz, Austria; twitter @chrisoutofspace; https://github.com/cmoestl
#
# **work in progress, last update September 2020**
#
# To install a conda environment, dependencies are listed under environment.yml, and pip in requirements.txt. Plots are saved in plots/ as png and pdf.
#
# **Data sources**
#
#
# In situ data need to be downloaded into a directory defined in config.py from this figshare repository:
# https://doi.org/10.6084/m9.figshare.11973693.v7
# (which can also be cited by DOI).
#
#
# **Packages not on pip**
#
# - 3DCORE install from https://github.com/ajefweiss/py3DCORE (clone, then pip install .)
#
#
#
# ---
# TO DO:
# - use HCI throughout; use orbits for inner spacecraft so they move correctly
#
#
# ---
#
# **MIT LICENSE**
#
# Copyright 2020, Christian Moestl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be included in all copies
# or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#
#
#
# In[3]:
import matplotlib
from matplotlib import cm
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import rc
import scipy.io
from scipy import stats
import sys
import numpy as np
from datetime import timedelta
from sunpy.time import parse_time
import sunpy.time
import time
import pickle
import seaborn as sns
import os
import copy
import urllib
import json
import warnings
import importlib
import heliopy.spice as spice
import heliopy.data.spice as spicedata
import astropy
import astropy.constants as const
#o
import py3dcore
import heliosat
#where the 6 in situ data files are located is read from input.py
#as data_path=....
from config import data_path
#Convert this notebook to a script with jupyter nbconvert --to script cme_rate.ipynb
os.system('jupyter nbconvert --to script cme_sig.ipynb')
#%matplotlib inline
#matplotlib.use('Qt5Agg')
#matplotlib.use('Agg')
#warnings.filterwarnings('ignore') # some numpy mean-of-empty-slice runtime warnings
########### make directories first time
resdir='plots'
if os.path.isdir(resdir) == False: os.mkdir(resdir)
datadir='data'
if os.path.isdir(datadir) == False: os.mkdir(datadir)
plt.rcParams["figure.figsize"] = (15,8)
# # **1) Settings and load data**
# In[4]:
plt.close('all')
print('cme_rate main program.')
print('Christian Moestl et al., IWF Graz, Austria')
#constants:
#solar radius
Rs_in_AU=float(const.R_sun/const.au)
#define AU in km
AU_in_km=const.au.value/1e3
#set for loading
load_data=0
if load_data > 0:
print('load data (takes a minute or so)')
print('')
################## Spacecraft
filemav='maven_2014_2018_removed_smoothed.p'
[mav,hmav]=pickle.load(open(data_path+filemav, 'rb' ) )
print('load and merge Wind data HEEQ')
#from HELCATS HEEQ until 2018 1 1 + new self-processed data with heliosat and hd.save_wind_data
filewin="wind_2007_2018_heeq_helcats.p"
[win1,hwin1]=pickle.load(open(data_path+filewin, "rb" ) )
#or use: filewin2="wind_2018_now_heeq.p"
filewin2="wind_2018_2019_heeq.p"
[win2,hwin2]=pickle.load(open(data_path+filewin2, "rb" ) )
#merge Wind old and new data
#cut off HELCATS data at end of 2017, win2 begins exactly after this
win1=win1[np.where(win1.time < parse_time('2018-Jan-01 00:00').datetime)[0]]
#make array
win=np.zeros(np.size(win1.time)+np.size(win2.time),dtype=[('time',object),('bx', float),('by', float), ('bz', float),('bt', float),('vt', float),('np', float),('tp', float), ('x', float),('y', float),('z', float), ('r', float),('lat', float),('lon', float)])
#convert to recarray
win = win.view(np.recarray)
win.time=np.hstack((win1.time,win2.time))
win.bx=np.hstack((win1.bx,win2.bx))
win.by=np.hstack((win1.by,win2.by))
win.bz=np.hstack((win1.bz,win2.bz))
win.bt=np.hstack((win1.bt,win2.bt))
win.vt=np.hstack((win1.vt,win2.vt))
win.np=np.hstack((win1.np,win2.np))
win.tp=np.hstack((win1.tp,win2.tp))
win.x=np.hstack((win1.x,win2.x))
win.y=np.hstack((win1.y,win2.y))
win.z=np.hstack((win1.z,win2.z))
win.r=np.hstack((win1.r,win2.r))
win.lon=np.hstack((win1.lon,win2.lon))
win.lat=np.hstack((win1.lat,win2.lat))
print('Wind merging done')
filevex='vex_2007_2014_sceq_removed.p'
[vex,hvex]=pickle.load(open(data_path+filevex, 'rb' ) )
filevex='vex_2007_2014_sceq.p'
[vexnon,hvexnon]=pickle.load(open(data_path+filevex, 'rb' ) )
filemes='messenger_2007_2015_sceq_removed.p'
[mes,hmes]=pickle.load(open(data_path+filemes, 'rb' ) )
filemes='messenger_2007_2015_sceq.p'
[mesnon,hmesnon]=pickle.load(open(data_path+filemes, 'rb' ) )
filestb='stereob_2007_2014_sceq.p'
[stb,hstb]=pickle.load(open(data_path+filestb, "rb" ) )
filesta='stereoa_2007_2019_sceq.p'
[sta,hsta]=pickle.load(open(data_path+filesta, "rb" ) )
filepsp='psp_2018_2019_sceq.p'
[psp,hpsp]=pickle.load(open(data_path+filepsp, "rb" ) )
fileuly='ulysses_1990_2009_rtn.p'
[uly,huly]=pickle.load(open(data_path+fileuly, "rb" ) )
fileomni='omni_1963_2020.p'
[omni,homni]=pickle.load(open(data_path+fileomni, "rb" ) )
print('load all data done')
# ############# get positions from a
# # pre-made IDL sav file for older spacecraft positions
# print()
# print('get positions')
# pos = hs.getcat('data/positions_2007_2023_HEEQ_6hours.sav')
# pos_time= hs.decode_array(pos.time)
# pos_time_num=parse_time(pos_time).plot_date
# print('positions done')
url='https://helioforecast.space/static/sync/icmecat/HELCATS_ICMECAT_v20.csv'
ic=pd.read_csv(url)
ic=ic.drop(columns='Unnamed: 0') #drop an extra index column
print('Keys (parameters) in this pandas data frame are:')
print(ic.keys())
print()
################### get indices of events for each spacecraft
mercury_orbit_insertion_time= parse_time('2011-03-18').datetime
#spacecraft near the 4 terrestrial planets
#get indices for Mercury after orbit insertion in March 2011
merci=np.where(np.logical_and(ic.sc_insitu =='MESSENGER', parse_time(ic.icme_start_time).datetime > mercury_orbit_insertion_time))[0]
vexi=np.where(ic.sc_insitu == 'VEX')[:][0]
wini=np.where(ic.sc_insitu == 'Wind')[:][0]
mavi=np.where(ic.sc_insitu == 'MAVEN')[:][0]
#other spacecraft
#all MESSENGER events including cruise phase
mesi=np.where(ic.sc_insitu == 'MESSENGER')[:][0]
pspi=np.where(ic.sc_insitu == 'ParkerSolarProbe')[:][0]
stai=np.where(ic.sc_insitu == 'STEREO-A')[:][0]
stbi=np.where(ic.sc_insitu == 'STEREO-B')[:][0]
ulyi=np.where(ic.sc_insitu == 'ULYSSES')[:][0]
# In[5]:
ic
# ## Define Functions
# In[80]:
def plot_configure(ax, **kwargs):
view_azim = kwargs.pop("view_azim", -25)
view_elev = kwargs.pop("view_elev", 25)
view_radius = kwargs.pop("view_radius", .5)
ax.view_init(azim=view_azim, elev=view_elev)
ax.set_xlim([-view_radius, view_radius])
ax.set_ylim([-view_radius, view_radius])
ax.set_zlim([-view_radius, view_radius])
ax.set_axis_off()
def plot_3dcore(ax, obj, t_snap, **kwargs):
kwargs["alpha"] = kwargs.pop("alpha", .05)
kwargs["color"] = kwargs.pop("color", "k")
kwargs["lw"] = kwargs.pop("lw", 1)
ax.scatter(0, 0, 0, color="y", s=500)
model_obj.propagate(t_snap)
wf_model = model_obj.visualize_wireframe(index=0)
ax.plot_wireframe(*wf_model.T, **kwargs)
def plot_3dcore_field(ax, obj, step_size=0.005, q0=[1, .1, np.pi/2],**kwargs):
#initial point is q0
q0i =np.array(q0, dtype=np.float32).astype(np.float32)
fl = model_obj.visualize_fieldline_dpsi(q0i, dpsi=2*np.pi-0.01, step_size=step_size)
ax.plot(*fl.T, **kwargs)
def plot_traj(ax, sat, t_snap, frame="HEEQ", traj_pos=True, traj_major=4, traj_minor=None, **kwargs):
kwargs["alpha"] = kwargs.pop("alpha", 1)
kwargs["color"] = kwargs.pop("color", "k")
kwargs["lw"] = kwargs.pop("lw", 1)
kwargs["s"] = kwargs.pop("s", 25)
inst = getattr(heliosat, sat)()
_s = kwargs.pop("s")
if traj_pos:
pos = inst.trajectory(t_snap, frame)
ax.scatter(*pos.T, s=_s, **kwargs)
if traj_major and traj_major > 0:
traj = inst.trajectory([t_snap + datetime.timedelta(hours=i) for i in range(-traj_major, traj_major)], frame)
ax.plot(*traj.T, **kwargs)
if traj_minor and traj_minor > 0:
traj = inst.trajectory([t_snap + datetime.timedelta(hours=i) for i in range(-traj_minor, traj_minor)], frame)
if "ls" in kwargs:
kwargs.pop("ls")
_ls = "--"
_lw = kwargs.pop("lw") / 2
ax.plot(*traj.T, ls=_ls, lw=_lw, **kwargs)
def plot_circle(ax,dist,**kwargs):
thetac = np.linspace(0, 2 * np.pi, 100)
xc=dist*np.sin(thetac)
yc=dist*np.cos(thetac)
zc=0
ax.plot(xc,yc,zc,ls='--',color='black',lw=0.3,**kwargs)
def plot_satellite(ax,satpos1,**kwargs):
xc=satpos1[0]*np.cos(np.radians(satpos1[1]))
yc=satpos1[0]*np.sin(np.radians(satpos1[1]))
zc=0
#print(xc,yc,zc)
ax.scatter3D(xc,yc,zc,**kwargs)
# # **2) 3DCORE modeling**
# ## Model Settings
# In[8]:
t_launch = datetime.datetime(2020, 1, 1, 0)
iparams_arr = np.array([[
0, # time offset
0, # l_1 (logitude) HEEQ
0, # l_2 (latitude)
0, # o (inclination, orientation)
0.24, # d_1au (frontal width at 1AU)
4, # delta (cross-section aspect ratio)
5, # r_0 (initialization distance in solar radii)
500, # v_0 (initial velocty in)
-1.5, # tau (magnetic field twist)
1.0, # b_s (magnetic field scaling parameter)
15, # b_1au (magnetic field strength at 1au)
1.5, # Gamma (solar wind drag coefficient)
400, # v_sw (solar wind speed)
0 # sigma (measurement noise)
]], dtype=np.float32)
model_obj = py3dcore.models.ThinTorusGH3DCOREModel(t_launch, runs=1, use_gpu=False)
model_obj.update_iparams(iparams_arr, seed=42)
#measurement times
tm0 = t_launch + datetime.timedelta(days=1)
tm1 = t_launch + datetime.timedelta(days=3.5)
tm2 = t_launch + datetime.timedelta(days=5.0)
#colors for 3dplots
c1 = "xkcd:red"
c2 = "xkcd:blue"
#colors for components in plots
cbt = "xkcd:black"
cbx = "xkcd:magenta"
cby = "xkcd:orange"
cbz = "xkcd:azure"
############# define synthetic satellite positions - semi-circle at 1 AU, from -90 to +90 longitude
lonstart=-90
lonstep=5
lonend=90
lonend=lonend+lonstep
satpos=np.zeros(len(np.arange(lonstart,lonend,lonstep)),dtype=[('r',float),('lon', float),('lat', float)])
#convert to recarray
satpos = satpos.view(np.recarray)
##### set position
satpos.r=1.0
satpos.lon=np.arange(lonstart,lonend,lonstep)
satpos.lat=0.0
print(satpos.r, satpos.lon)
#another satpos definition for a semi circle at 0.5 AU
satpos2=copy.deepcopy(satpos)
satpos2.r=0.5
# ## Figure 1 model setup Nr.1 for illustration
# In[87]:
#use either
#%matplotlib
#%matplotlib inline
#matplotlib.use('Qt5Agg')
#matplotlib.use('Agg')
#%matplotlib inline
sns.set_context("talk")
#sns.set_style('whitegrid',{'grid.linestyle': '--'})
sns.set_style("ticks",{'grid.linestyle': '--'})
fsize=15
fig=plt.figure(1,figsize=(12,9),dpi=70)
ax = fig.add_subplot(111, projection='3d')
plot_configure(ax, view_azim=-50, view_elev=40, view_radius=0.6)
#in other planes
#plot_configure(ax, view_azim=0, view_elev=90, view_radius=0.7)
#plot_configure(ax, view_azim=0, view_elev=0, view_radius=0.6)
########## 3dcore plots
plot_3dcore(ax, model_obj, tm0, color=c1)
plot_3dcore_field(ax, model_obj, color=c1, step_size=0.005, lw=1.1, ls="-",q0=np.array([1, .1, np.pi/2]))
plot_3dcore(ax, model_obj, tm1, color=c2)
plot_3dcore_field(ax, model_obj, color=c2, step_size=0.005, lw=1.1, ls="-")
############# satellite plots
#plot_traj(ax, "Earth", tm1, frame="HEEQ", color=c1)
for i in np.arange(0,len(satpos)):
plot_satellite(ax,satpos[i],color='black',alpha=0.9)
plot_satellite(ax,satpos2[i],color='red',alpha=0.9)
##########cosmetics
#approximate Sun Earth line
ax.plot([0,1],[0,0],[0,0],ls='-',color='black',lw=0.3)
plot_circle(ax,0.5)
plot_circle(ax,1.0)
#plot_traj(ax, "PSP", TP_B, frame="ECLIPJ2000", color=C_B,lw=1.5)
#plot_traj(ax, "PSP", TP_B, frame="ECLIPJ2000", color="k", traj_pos=False, traj_major=None, traj_minor=144,lw=1.5)
plt.tight_layout()
plt.savefig('plots/fig1_setup.pdf')
plt.savefig('plots/fig1_setup.png', dpi=100)
# ## Figure 2: Measure components for simple case
# In[10]:
def measure(obj, satpos1, t0, t1, frame="HEEQ", bframe="HEEQ", satparams=None):
#print(obj)
print('input')
print(t0,' / ', t1, frame, bframe)
#if satparams:
# inst = getattr(heliosat, sat)(satparams)
#else:
# inst = getattr(heliosat, sat)()
#print(inst)
#time resolution in seconds
#t_s = [datetime.datetime.fromtimestamp(_) for _ in np.array(list(range(int(t0.timestamp()), int(t1.timestamp()))))]
#position of spacecraft
#o_s = inst.trajectory(t_s, frame=frame)
#time resolution in hours
res_in_days=1/24.
t_s = []
while t0 < t1:
t_s.append(t0)
t0 += timedelta(days=res_in_days)
print('data points',len(t_s))
#generate position from satpos - always constant
o_s=np.zeros([len(t_s),3])
o_s[:,0]=satpos1[0] #R in AU
o_s[:,1]=np.radians(satpos1[1]) #longitude
o_s[:,2]=np.radians(satpos1[2]) #latitude
#print(t_s)
#print(o_s)
if satparams:
b = heliosat.spice.transform_frame([satparams] * len(t_s), np.array(obj.sim_fields(t_s, o_s))[:, 0, :], frame, bframe)
else:
b = heliosat.spice.transform_frame(t_s, np.array(obj.sim_fields(t_s, o_s))[:, 0, :], frame, bframe)
b[b == 0] = np.nan
return t_s, np.sqrt(np.sum(b**2, axis=1)), b, o_s
# In[8]:
t_launch = datetime.datetime(2020, 1, 1, 0)
iparams_arr = np.array([[
0, # time offset
0, # l_1 (logitude) HEEQ
0, # l_2 (latitude)
0, # o (inclination, orientation)
0.2, # d_1au (frontal width at 1AU)
5, # delta (cross-section aspect ratio)
5, # r_0 (initialization distance in solar radii)
500, # v_0 (initial velocty in)
-1.0, # tau (magnetic field twist)
1.0, # b_s (magnetic field scaling parameter)
15, # b_1au (magnetic field strength at 1au)
1.5, # Gamma (solar wind drag coefficient)
400, # v_sw (solar wind speed)
0 # sigma (measurement noise)
]], dtype=np.float32)
model_obj = py3dcore.models.ThinTorusGH3DCOREModel(t_launch, runs=1, use_gpu=False)
model_obj.update_iparams(iparams_arr, seed=42)
############################### measure magnetic field
print()
start=time.time()
#18 is middle
satposindex=20
print('current satpos measured is ', satposindex)
#t0, btot0, bxyz0, os = measure(model_obj, satpos[6], tm1 - datetime.timedelta(days=3), tm1 + datetime.timedelta(days=20))
t1, btot1, bxyz1, os1 = measure(model_obj, satpos[satposindex], tm1 - datetime.timedelta(days=3), tm1 + datetime.timedelta(days=15))
#t2, btot2, bxyz2, os = measure(model_obj, satpos[30], tm1 - datetime.timedelta(days=3), tm1 + datetime.timedelta(days=20))
print('took ', np.round(time.time()-start,3), ' seconds')
print()
#print(t1)
#print(os1)
################################################
sns.set_context('talk')
sns.set_style('whitegrid')
fig = plt.figure(figsize=(15, 12),dpi=50)
ax1 = fig.add_subplot(111)
ax1.set_title('Satellite position R= 1.0 AU, longitude '+str(satpos.lon[satposindex])+' HEEQ ***')
ax1.plot(t1, btot1, color=cbt, label="$|B|$")
ax1.plot(t1, bxyz1[:, 0], color=cbx, label="$B_R$")
ax1.plot(t1, bxyz1[:, 1], color=cby, label="$B_T$")
ax1.plot(t1, bxyz1[:, 2], color=cbz, label="$B_N$")
ax1.legend(loc="lower right", fontsize=20,ncol=4)
ax1.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('d%d %H:00'))
ax1.set_ylabel('B [nT]')
#plt.ylim(-1300,1300)
#plt.xlim(datetime.datetime(2022,6,1,23,0),datetime.datetime(2022,6,2,4,0))
plt.tight_layout()
#plt.savefig('plots/fig2_measure_1.pdf', dpi=300)
#plt.savefig('plots/fig2_measure_1.png', dpi=300)
# ### **3) Parameter analysis** - vary orientation, speed, size, flattening
#
# ### what if we vary parameters - do we find any weird signatures?
#
# results: delta up, twist down -> same signature
# back regions -> expansion, FR large, better for back region
#
#
#
#
# In[ ]:
def plot_reconstruction(ax, obj, qs, **kwargs):
ss = []
for i in range(len(qs)):
q = np.array([qs[i]])
s = np.empty_like(q)
obj.transform_qs(s, q)
ss.append(s[0])
ss = np.array(ss)
ax.plot(*ss.T, **kwargs)
def reconstruct_path(obj, sat, t0, t1, frame="HEEQ", satparams=None):
if satparams:
inst = getattr(heliosat, sat)(satparams)
else:
inst = getattr(heliosat, sat)()
t_s = [datetime.datetime.fromtimestamp(_) for _ in np.array(list(range(int(t0.timestamp()), int(t1.timestamp()))))]
o_s = inst.trajectory(t_s, frame=frame)
qs = []
for i in range(len(t_s)):
s = np.array([o_s[i]])
q = np.empty_like(s)
obj.propagate(t_s[i])
obj.transform_sq(s, q)
if q[0][0] < 1.0:
qs.append(np.copy(q[0]))
return qs
# In[ ]:
QPATH_PSP = reconstruct_path(model_obj, "PSP", TP_A - datetime.timedelta(hours=3), TP_A + datetime.timedelta(hours=3), frame="ECLIPJ2000")
QPATH_PSP_FIXED = reconstruct_path(model_obj, "PSP_FIXED", TP_A - datetime.timedelta(hours=3), TP_A + datetime.timedelta(hours=3), frame="ECLIPJ2000", satparams=TP_A)
# In[ ]:
fig = plt.figure(figsize=(20, 20),dpi=50)
ax = fig.add_subplot(111, projection='3d')
plot_configure(ax, view_azim=80, view_elev=75, view_radius=.05)
plot_3dcore(ax, model_obj, TP_A, color=C0)
plot_3dcore_field(ax, model_obj, color=C0, steps=400, step_size=0.0005, lw=.5, ls=":")
plot_reconstruction(ax, model_obj, QPATH_PSP, color="c", ls="-", lw=2)
plot_reconstruction(ax, model_obj, QPATH_PSP_FIXED, color="m", ls="-", lw=2)
plt.tight_layout()
# ***
# # 3 Parameter analysis - vary orientation, speed, size
# In[ ]: