def testOpen(self): # Open file, ensure values are read properly. sat = pbs.VirtSat('data/pybats_test/sat_multispecies.sat') self.assertEqual(self.knownSatXmax, sat['x'].max()) self.assertEqual(self.knownSatPmax, sat['p'].max()) self.assertEqual(self.knownSatHmax, sat['rhoh'].max()) self.assertEqual(self.knownSatOmax, sat['rhoo'].max())
def testCalc(self): # Test various unit calculations sat = pbs.VirtSat('data/pybats_test/sat_multispecies.sat') # Test calculation of species number density: sat.calc_ndens() self.assertTrue('N' in sat) self.assertEqual(100, sat['oFrac'][0]+sat['hFrac'][0]+sat['heFrac'][0])
def testOpen(self): # Open file, ensure values are read properly. sat = pbs.VirtSat( os.path.join(spacepy_testing.datadir, 'pybats_test', 'sat_multispecies.sat')) self.assertEqual(self.knownSatXmax, sat['x'].max()) self.assertEqual(self.knownSatPmax, sat['p'].max()) self.assertEqual(self.knownSatHmax, sat['rhoh'].max()) self.assertEqual(self.knownSatOmax, sat['rhoo'].max())
def testCalc(self): # Test various unit calculations sat = pbs.VirtSat( os.path.join(spacepy_testing.datadir, 'pybats_test', 'sat_multispecies.sat')) # Test calculation of species number density: sat.calc_ndens() self.assertTrue('N' in sat) self.assertEqual(100, sat['oFrac'][0] + sat['hFrac'][0] + sat['heFrac'][0])
if args.obsdst: if not log.fetch_obs_dst(): raise ValueError('Failed to obtain observed Dst. Is KyotoWDC down?') imf.calc_pram() if end: end = parse(end) else: end = log['time'][-1] trange = [start, end] sats = [] if args.sats: for s in glob(prefix + "*.sat"): sats.append(pbs.VirtSat(s)) if sats: print('\tVirtSats: found {} virtual satellites'.format(len(sats))) if args.nthread > 1: print('\tParallel: using {} threads.'.format(args.nthread)) # Create function for generating plots. def plot_results(fileY, fileZ, iFile=0, nFiles=1): ''' Create a nice plot of WTF is happening. Kwargs iFile and nFiles are for reporting progress. ''' # Get start times from file names:
def calc_tdiff(t1, arrival=arrival): t_out = np.array([(t1[i] - arrival).total_seconds() for i in range(t1.size)]) return t_out ################################ # MAIN SCRIPT ################################ # Open all files, stash them into a list: sats = [] for f in glob(path + 'sat*.sat'): # Loop over all files in directory. # Load file, stash it into the satellite file. sats.append(bats.VirtSat(f)) # Create an alternative time value relative to the time when # the shock wave hits the bow shock: # Create a beautiful plot: fig = plt.figure(figsize=[8.25, 5.75]) ax = fig.add_subplot(111) # Plot each virtual satellite result: for s in sats: # Convert time into time from impact on magnetosphere: t_now = calc_tdiff(s['time']) # Add line to plot: ax.plot(t_now, s['b1z'], label=f'{s["x"][0]:.1f} $R_E$', lw=2) # Add two vertical lines to mark shock arrival into