コード例 #1
0
ファイル: pkrasi.py プロジェクト: aldebaran1/pkrasi
def returnRaw(folder, azfn=None, elfn=None, wl=558, timelim=[]):
    t1 = datetime.now()
    data = read_asi.load(folder,
                         azfn=azfn,
                         elfn=elfn,
                         wavelenreq=wl,
                         treq=timelim)
    print('Data loaded in {}'.format(datetime.now() - t1))

    return data
コード例 #2
0
def main():
    p = ArgumentParser(description="register/plot other camera FOV onto Themis FOV")
    p.add_argument("themiscal", help="ASI calibration")
    p.add_argument("dasccal", help="DASC cal", nargs=3)
    p.add_argument("-o", "--ofn", help="write output plot")
    P = p.parse_args()

    # %% load data
    themis = ta.loadcal(P.themiscal)
    dasc = dio.load(*P.dasccal)
    # %% merge FOV
    # paint HiST field of view onto Themis
    themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method="perimeter")
    # %% plot joint az/el contours
    tap.jointazel(themis, P.ofn, "Themis Gakona overlaid on Poker Flat ASI")

    show()
コード例 #3
0
def main():
    p = ArgumentParser(
        description="register/plot other camera FOV onto Themis FOV")
    p.add_argument("themiscal", help="ASI calibration")
    p.add_argument("dasccal", help="DASC cal", nargs=3)
    p.add_argument("-o", "--ofn", help="write output plot")
    p.add_argument("-v", "--verbose", action="store_true")
    P = p.parse_args()

    # %% load az/el data
    themis = ta.loadcal(P.themiscal)
    if themis.site == "gako":
        themis.attrs["Baz"] = 21.028
        themis.attrs["Bel"] = 75.816
        themis.attrs["Bepoch"] = "2010-01-01"
        themis.attrs["verbose"] = False
        themis.attrs["srpts"] = np.logspace(5, 6.9, 40)
        themis["cutcol"] = np.arange(50, themis.x.size - 75, 1, dtype=int)

    dasc = dio.load(*P.dasccal)
    if "lat" not in dasc.attrs:
        dasc.attrs["lat"] = 65.126
        dasc.attrs["lon"] = -147.479
        dasc.attrs["alt_m"] = 200.0
        dasc.attrs["Baz"] = 21.145  # Baz = declination
        dasc.attrs["Bel"] = 77.464  # Bel = inclination
        dasc.attrs["Bepoch"] = "2010-01-01"
        dasc.attrs["verbose"] = False
        # np.linspace(10**4.6,10**6.8,40) #np.logspace(4.6, 6.4, 40)
        dasc.attrs["srpts"] = np.logspace(4.6, 7.5, 40)
        dasc["cutcol"] = np.arange(75, dasc.x.size - 100, 1, dtype=int)
    # %% extract common 2-D slice (plane)
    # paint HiST field of view onto Themis
    themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method="MZslice")
    themis = taf.line2plane(themis)
    dasc = taf.line2plane(dasc)
    if show is None:
        return
    # %% plot slice pixel mask
    tap.jointazel(themis, P.ofn,
                  "Themis Gakona slice toward DASC and magnetic zenith")
    tap.jointazel(
        dasc, P.ofn,
        "DASC Poker Flat slice toward Themis Gakona and magnetic zenith")

    show()
コード例 #4
0
@author: Raymond
"""
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import dascutils.io as dio
import pymap3d as pm
from pathlib import Path

PC = ccrs.PlateCarree()
ST = ccrs.Stereographic()
MR = ccrs.Mercator()
R = Path('~/code/dascutils/').expanduser()

dat = dio.load(R / 'tests', R / 'cal/PKR_DASC_20110112')
img = dat[428].isel(time=1).values
# %% coord conv.
alt = 100000
srange = alt / np.sin(np.radians(dat.el.values))
lat, lon, alt = pm.aer2geodetic(dat.az.values, dat.el.values, srange, dat.lat,
                                dat.lon, 0)

mask = np.isfinite(lat)
top = None
for i, m in enumerate(mask):
    good = m.nonzero()[0]

    if good.size == 0:
        continue
    elif top is None:
コード例 #5
0
ファイル: pkrasi.py プロジェクト: aldebaran1/pkrasi
def returnASpolar(folder,
                  azfn=None,
                  elfn=None,
                  wl=558,
                  timelim=[],
                  Nim=512,
                  asi=False,
                  el_filter=None):
    # Read in the data utliizing DASCutils
    print('Reading the data')
    t1 = datetime.now()
    data = read_asi.load(folder,
                         azfn=azfn,
                         elfn=elfn,
                         wavelenreq=wl,
                         treq=timelim)
    print('Data loaded in {}'.format(datetime.now() - t1))
    # Get time vector as datetime
    T = data.time.values.astype(datetime)
    print('Data reducted from {0} to {1}'.format(T.shape[0], T.shape[0]))
    # Get Az and El grids
    az = data.az[1]
    el = data.el[1]
    # Camera position
    lat0 = data.lat
    lon0 = data.lon
    alt0 = data.alt_m
    # Reshape image calibration if needed
    im_test = data[wl][0].values
    if im_test.shape[0] != el.shape[0]:
        el = interpolateCoordinate(el, N=im_test.shape[0])
        az = interpolateCoordinate(az, N=im_test.shape[0])
    # Elivation filter/mask
    if el_filter is not None and isinstance(el_filter, int):
        el = np.where(el >= el_filter, el, np.nan)
        az = np.where(el >= el_filter, az, np.nan)
    # Image size
    if Nim is None or (not isinstance(Nim, int)):
        Nim = az.shape[0]
    # Prepare a polar projection to cartesian
    rel = 90 - el
    x = rel * np.cos(np.deg2rad(az))
    y = rel * np.sin(np.deg2rad(az))
    # Mask NaNs
    #    mask = np.ma.masked_invalid(x)
    #    x = x[~mask.mask]
    #    y = y[~mask.mask]
    # Make an empty image array
    imae = np.nan * np.ones((T.shape[0], Nim, Nim))
    # Interpolation grid
    # Input grid
    #    X,Y = np.mgrid[np.nanmin(x):np.nanmax(x):x.shape[0]*1j,
    #                   np.nanmin(y):np.nanmax(y):y.shape[0]*1j]
    #    xy=np.zeros([X.shape[0] * x.shape[1],2])
    #    xy[:,0]=X.flatten()
    #    xy[:,1]=Y.flatten()

    # Output grid
    #    uv=np.zeros([Nim*Nim,2])
    #    Xi, Yi = np.mgrid[-80:80:Nim*1j,
    #                      -80:80:Nim*1j]
    #    uv[:,0]=Yi.flatten()
    #    uv[:,1]=Xi.flatten()
    #    vtx, wts = interp_weights(xy, uv)
    for i in range(T.shape[0]):
        print('Processing-interpolating {}/{}'.format(i + 1, T.shape[0]))
        # Read a raw image
        im = np.rot90(data[wl][i].values, -1)
        #Interpolate Polar
        xgrid, ygrid, Zim = interpolatePolar(x, y, im, Nim)
        #        Zim=interpolate(im.flatten(), vtx, wts)
        Zim = Zim.reshape(Nim, Nim)
        # Assign to array
        imae[i, :, :] = Zim
    if asi:
        return T, xgrid, ygrid, imae, [lon0, lat0, alt0]
    else:
        return T, xgrid, ygrid, imae
コード例 #6
0
ファイル: pkrasi.py プロジェクト: aldebaran1/pkrasi
def returnASLatLonAlt(folder,
                      azfn=None,
                      elfn=None,
                      wl=558,
                      timelim=[],
                      alt=130,
                      Nim=512,
                      el_filter=None,
                      asi=False,
                      verbose=False):
    # Mapping altitude to meters
    mapping_alt = alt * 1e3
    # Read in the data utliizing DASCutils
    print('Reading the PKR asi images')
    t1 = datetime.now()
    data = read_asi.load(folder,
                         azfn=azfn,
                         elfn=elfn,
                         wavelenreq=wl,
                         treq=timelim,
                         verbose=verbose)
    print('Data loaded in {}'.format(datetime.now() - t1))
    # Get time vector as datetime
    T = data.time.values.astype(datetime)
    # Get Az and El grids
    az = data.az[1]
    el = data.el[1]
    # Reshape image calibration if needed
    im_test = data[wl][0].values
    if im_test.shape[0] != el.shape[0]:
        el = interpolateCoordinate(el, N=im_test.shape[0])
        az = interpolateCoordinate(az, N=im_test.shape[0])
    # Elivation filter/mask
    if el_filter is not None and isinstance(el_filter, int):
        el = np.where(el >= el_filter, el, np.nan)
        az = np.where(el >= el_filter, az, np.nan)
    # Image size
    if Nim is None or (not isinstance(Nim, int)):
        Nim = az.shape[0]
    ########################## Convert into WSG84 #############################
    # Map to altitude
    r = mapping_alt / np.sin(np.deg2rad(el))
    # Convert to WSG
    lat0 = data.lat
    lon0 = data.lon
    alt0 = data.alt_m
    lat, lon, alt = aer2geodetic(az, el, r, lat0, lon0, alt0)
    # Make an empty image array
    imlla = np.nan * np.ones((T.shape[0], Nim, Nim))
    #    c = 0
    for i in range(T.shape[0]):
        print('Processing-interpolating {}/{}'.format(i + 1, T.shape[0]))
        # Read a raw image
        im = data[wl][i].values
        #Interpolate Lat Lon to preset Alt
        xgrid, ygrid, Zim = interpolateAS(lon, lat, im, N=Nim)
        # Assign to an array
        imlla[i, :, :] = Zim


#        c += 1

    if asi:
        return T, xgrid, ygrid, imlla, [lon0, lat0, alt0]
    else:
        return T, xgrid, ygrid, imlla