def main1(): Obj = pyapex.ApexFL() year, doy = 2003, 323 date = 2003. + doy / 365 dlon = -75. hlim = [80., 160.] f = figure(figsize=(16, 6)) pn = f.add_subplot(111) for h in arange(hlim[0], hlim[1] + 10., 10.): gc, qc = Obj.getFL(date=date, dlon=dlon, hateq=h, verbose=False) x, y, z = gc['lat'], gc['alt'], gc['lon'] ind = where(y < (hlim[0] - 10.)) if len(ind) > 0: x[ind], y[ind], z[ind] = nan, nan, nan pn.plot(x, y) strDate = 'DATE: {:4d}.{:03d}'.format(year, doy) strLoc = 'GEOG. LON.: {:6.2f}$^\circ${:s}'.format( abs(dlon), 'E' if dlon > 0. else 'W') title = '{:s} - {:s}'.format(strDate, strLoc) pn.set_title(title) pn.set_ylim([hlim[0] - 1, hlim[1] + 1]) pn.set_xlabel("Geog. Lat. ($^\circ$)") pn.set_ylabel("Altitude (km)") pn.invert_xaxis() show()
def LatVsFL(self, date=[2003, 11, 21], time=[23, 15, 0], gc=[-77.76, -11.95], hlim=[80., 200.], hstp=1., mlatlim=[-10., 10.], mlatstp=.1): # # INPUTS # # Date year, month, day = date self.year, self.month, self.day = year, month, day # Time hour, minute, second = time self.hour, self.minute, self.second = hour, minute, second # Geog. Coord. dlon, dlat = gc self.dlon, self.dlat = dlon, dlat # hlim -> Height range at equator, in km # hstp -> height resolution at equator, in km # mlatlim -> Geom. latitude range, in degrees # mlatstp -> Geom. latitude resolution, in degrees # ### self.hlim = hlim self.doy = TimeUtilities().CalcDOY(year, month, day) date = year + self.doy / (365 + 1 if TimeUtilities().IsLeapYear else 0) self.coordl = [] for h in arange(hlim[0], hlim[1] + hstp, hstp): gc, qc = pyapex.ApexFL().getFL(date=date, dlon=dlon, dlat=dlat, hateq=h, mlatRange=mlatlim, mlatSTP=mlatstp) self.coordl.append([gc['lon'], gc['alt'], gc['lat']]) self.coordl = asarray(self.coordl) # nfl -> No. of field-line (or height) # nc -> No. of coord. (0 -> lon, 1 -> alt, 2 -> lat) # np -> No. of points per field-line nfl, nc, np = self.coordl.shape self.Uwind, self.Vwind = tile(nan, (np, nfl)), tile(nan, (np, nfl)) iyd = int((year - (2000 if year >= 2000 else 1900)) * 1e3) + self.doy sec = (hour + minute / 60 + second / 3600) * 3600 stl, f107a, f107, ap = 17., 90, 90, [2, 2] self.stl, self.f107a, self.f107, ap = stl, f107a, f107, ap for fl in range(nfl): curr_coordl = transpose(self.coordl[fl, :, :]) ind = where(curr_coordl[:, 1] >= hlim[0]) if len(ind[0]) > 0: ns, dummy = curr_coordl[ind[0], :].shape for s in range(ns): glon, alt, glat = curr_coordl[ind[0][s], :] w = hwm14.hwm14(iyd, sec, alt, glat, glon, stl, f107a, f107, ap) self.Uwind[ind[0][s], fl] = w[1] self.Vwind[ind[0][s], fl] = w[0]
def LatVsFL( self, date=[2003, 11, 21], FIRI=False, IGRF=False, time=[23, 15, 0], gc=[-77.76, -11.95], hlim=[80.0, 200.0], hstp=1.0, mlatlim=[-10.0, 10.0], mlatstp=0.1, ): if pyapex is None: logging.error("PyApex is needed for LatVsFL") return # Date year, month, day = date # Time hour, minute, second = time # Geog. Coord. dlon, dlat = gc # hlim -> Height range at equator, in km # hstp -> height resolution at equator, in km # mlatlim -> Geom. latitude range, in degreesgetIGRF # mlatstp -> Geom. latitude resolution, in degrees # ### doy = TimeUtilities().CalcDOY(year, month, day) date2 = year + doy / (365 + 1 if TimeUtilities().IsLeapYear else 0) # f = figure(figsize=(16,6)) # pn = f.add_subplot(111) self.coordl, self.qdcoordl = [], [] for h in arange(hlim[0], hlim[1] + hstp, hstp): gc, qc = pyapex.ApexFL().getFL(date=date2, dlon=dlon, dlat=dlat, hateq=h, mlatRange=mlatlim, mlatSTP=mlatstp) # x, y, z = gc['lat'], gc['alt'], gc['lon'] # ind = where(y < hlim[0]) # if len(ind) > 0: x[ind], y[ind], z[ind] = nan, nan, nan # pn.plot(x, y) self.coordl.append([gc["lon"], gc["alt"], gc["lat"]]) self.qdcoordl.append([qc["lon"], gc["alt"], qc["lat"]]) # pn.invert_xaxis() # show() jf = IRI().Switches() jmag = 0 mmdd = int(month * 100) + day hour2 = hour + minute / 60 + second / 3600 self.coordl = array(self.coordl) self.qdcoordl = array(self.qdcoordl) # nfl -> No. of field-line (or height) # nc -> No. of coord. (0 -> lon, 1 -> alt, 2 -> lat) # np -> No. of points per field-line nfl, nc, np = self.coordl.shape self.ne, self.te = tile(nan, (np, nfl)), tile(nan, (np, nfl)) self.ti, self.tn = tile(nan, (np, nfl)), tile(nan, (np, nfl)) self.nHe, self.nO = tile(nan, (np, nfl)), tile(nan, (np, nfl)) self.nN2, self.nO2 = tile(nan, (np, nfl)), tile(nan, (np, nfl)) self.nAr, self.nH = tile(nan, (np, nfl)), tile(nan, (np, nfl)) self.nN, self.babs = tile(nan, (np, nfl)), tile(nan, (np, nfl)) if FIRI: self.neFIRI = tile(nan, (np, nfl)) for fl in range(nfl): curr_coordl = transpose(self.coordl[fl, :, :]) ind = where(curr_coordl[:, 1] >= (hlim[0] - 10.0)) if len(ind[0]) > 0: outf, oarr = iri2016.irisubgl(jf, jmag, year, mmdd, hour2, curr_coordl[ind[0], :], DataFolder) self.ne[ind[0], fl] = outf[0, :] self.tn[ind[0], fl] = outf[1, :] self.ti[ind[0], fl] = outf[2, :] self.te[ind[0], fl] = outf[3, :] if FIRI: self.neFIRI[ind[0], fl], ierr = iri2016.firisubl( year, doy, hour2, curr_coordl[ind[0], :], DataFolder) self.nHe[ind[0], fl] = outf[20, :] self.nO[ind[0], fl] = outf[21, :] self.nN2[ind[0], fl] = outf[22, :] self.nO2[ind[0], fl] = outf[23, :] self.nAr[ind[0], fl] = outf[24, :] self.nH[ind[0], fl] = outf[26, :] self.nN[ind[0], fl] = outf[27, :] if IGRF: self.babs[ind[0], fl] = list( self.getIGRF(curr_coordl[ind[0], :], date2)) else: self.babs[ind[0], fl] = outf[19, :] self.hlim = hlim self.date, self.time = date, time self.f107cm = oarr[40, 0] self.ap, self.Ap = oarr[50, 0], oarr[51, 0]