Ejemplo n.º 1
0
def plot_many_sunearth_vec(d, comveceq, obsveceq, ctime, ltcomcel, axisdata,
                           ra_img_higher, ra_img_lower, border, pixwidth,
                           pixheight, rafmin, decmin, scale, comsunfill,
                           featur_fill, fnt, fixwrapsbool):
    nolines = 24
    lperday = 24
    timearray = np.empty((nolines, 2), dtype=float)
    timearray[:,
              0] = np.arange(-0.5, -0.5 - nolines / lperday, -1 /
                             lperday) + np.floor(ctime.jd * lperday) / lperday

    for ta in range(nolines):
        timearray[ta, 1] = abs(comveceq[:, 0] - timearray[ta, 0]).argmin()

    for n in range(nolines):
        #creates an array of ra/dec values along sun-comet line
        cmsam = 10001
        offsets = np.ones(cmsam) + np.linspace(-1, 1, cmsam)
        comsun = np.empty((cmsam, 4), dtype=float)
        for cs in range(0, cmsam):
            ctemp = pos2radec(
                offsets[cs] * comveceq[timearray[n, 1], 6:9] -
                obsveceq[ltcomcel, 6:9], fixwrapsbool)
            comsun[cs, 0] = ctemp[0]
            comsun[cs, 1] = ctemp[1]

        #slims this array down to within image limits
        csvrange = np.intersect1d(
            np.intersect1d(
                np.where(comsun[:, 0] < ra_img_higher)[0],
                np.where(comsun[:, 0] > ra_img_lower)[0]),
            np.intersect1d(
                np.where(comsun[:, 1] < axisdata[9])[0],
                np.where(comsun[:, 1] > axisdata[8])[0]))
        comsun = comsun[csvrange[0]:csvrange[-1], :]

        #convert to ra and dec, and plot
        comsun[:, 2] = ra2xpix(comsun[:, 0], border, pixwidth, rafmin, scale)
        comsun[:, 3] = dec2ypix(comsun[:, 1], border, pixheight, decmin, scale)
        for ca in range(0, (np.shape(comsun)[0] - 1)):
            d.line([(comsun[ca, 2], comsun[ca, 3]),
                    (comsun[ca + 1, 2], comsun[ca + 1, 3])],
                   fill=comsunfill)
Ejemplo n.º 2
0
def plot_sunearth_vec_ecliptic(d, comveceq, obsveceq, ltcomcel, axisdata,
                               ra_img_higher, ra_img_lower, border, pixwidth,
                               pixheight, rafmin, decmin, scale, comsunfill,
                               featur_fill, fnt, fixwrapsbool):

    #creates an array of ra/dec values along sun-comet line
    cmsam = 10001
    offsets = np.ones(cmsam) + np.linspace(-1, 1, cmsam)
    comsun = np.empty((cmsam, 4), dtype=float)
    for cs in range(0, cmsam):
        ctemp = ecliptic_pos2radec(
            offsets[cs] * comveceq[ltcomcel, 6:9] - obsveceq[ltcomcel, 6:9],
            fixwrapsbool)
        comsun[cs, 0] = ctemp[0]
        comsun[cs, 1] = ctemp[1]

    #slims this array down to within image limits
    csvrange = np.intersect1d(
        np.intersect1d(
            np.where(comsun[:, 0] < ra_img_higher)[0],
            np.where(comsun[:, 0] > ra_img_lower)[0]),
        np.intersect1d(
            np.where(comsun[:, 1] < axisdata[9])[0],
            np.where(comsun[:, 1] > axisdata[8])[0]))
    comsun = comsun[csvrange[0]:csvrange[-1], :]

    #convert to ra and dec, and plot
    comsun[:, 2] = ra2xpix(comsun[:, 0], border, pixwidth, rafmin, scale)
    comsun[:, 3] = dec2ypix(comsun[:, 1], border, pixheight, decmin, scale)
    for ca in range(0, (np.shape(comsun)[0] - 1)):
        d.line([(comsun[ca, 2], comsun[ca, 3]),
                (comsun[ca + 1, 2], comsun[ca + 1, 3])],
               fill=comsunfill)

    d.text((2*border + pixwidth + 30,border + 310), \
    "Comet-Sun\nVector:",font=fnt, fill= featur_fill)
    d.line([(2 * border + pixwidth + 30, border + 355),
            (2 * border + pixwidth + 170, border + 355)],
           fill=comsunfill)
Ejemplo n.º 3
0
#initialise comet box path
com_box_path = np.zeros((2 * sum(np.shape(ra)) - 3, 2), dtype=float)
len1 = np.shape(ra)[0]
len0 = np.shape(ra)[1]
com_box_path[0:len0, 0] = ra[0, :]
com_box_path[0:len0, 1] = dec[0, :]
com_box_path[len0:len0 + len1 - 1, 0] = ra[1:, -1]
com_box_path[len0:len0 + len1 - 1, 1] = dec[1:, -1]
com_box_path[len0 + len1 - 1:2 * len0 + len1 - 2, 0] = ra[-1, -2::-1]
com_box_path[len0 + len1 - 1:2 * len0 + len1 - 2, 1] = dec[-1, -2::-1]
com_box_path[2 * len0 + len1 - 2:2 * len0 + 2 * len1 - 3, 0] = ra[-2::-1, 0]
com_box_path[2 * len0 + len1 - 2:2 * len0 + 2 * len1 - 3, 1] = dec[-2::-1, 0]
com_Path = mplPath.Path(com_box_path)

comlocra = ra2xpix(comobs[:, 5], border, pixwidth, rafmin, scale)
comlocdec = dec2ypix(comobs[:, 6], border, pixheight, decmin, scale)

decgoodlocs = np.where((comlocdec < (imgheight - border * 1.5))
                       & (comlocdec > border * 1.5))[0]
ragoodlocs = np.where((comlocra < (imgwidth - border * 2.5))
                      & (comlocra > border * 1.5))[0]
goodlocs = np.intersect1d(decgoodlocs, ragoodlocs)

for o in range(0, np.size(goodlocs) - 1):
    ocel = goodlocs[o]
    d.line([(comlocra[ocel], comlocdec[ocel]),
            (comlocra[ocel + 1], comlocdec[ocel + 1])],
           fill=(255, 0, 0, 255))

if not os.path.exists(os.path.join(imagedir, 'imgtime_test')):
Ejemplo n.º 4
0
maskfits = fits.open(mask2loc)
imagemask2 = (maskfits[0].data[::2, ::2])[:-1, :-1]

non_zeros_01 = np.where(imagemask1 == 1)[0]
non_zeros_11 = np.where(imagemask1 == 1)[1]
no_points1 = non_zeros_01.size

non_zeros_02 = np.where(imagemask2 == 1)[0]
non_zeros_12 = np.where(imagemask2 == 1)[1]
no_points2 = non_zeros_02.size

non_zeros_03 = np.where(imagemask3 == 1)[0]
non_zeros_13 = np.where(imagemask3 == 1)[1]
no_points3 = non_zeros_03.size

rp1 = ra2xpix(ra_m1, border, pixwidth, trafmin, scale)
dp1 = dec2ypix(dec1, border, pixheight, tdecmin, scale)

rp2 = ra2xpix(ra_m2, border, pixwidth, trafmin, scale)
dp2 = dec2ypix(dec2, border, pixheight, tdecmin, scale)

rp3 = ra2xpix(ra_m3, border, pixwidth, trafmin, scale)
dp3 = dec2ypix(dec3, border, pixheight, tdecmin, scale)

for xp in range(0, no_points3):
    x = non_zeros_03[xp]
    y = non_zeros_13[xp]
    plotpixel2(d, x, y, rp3, dp3, colplot3[x, y], colplot3[x, y], colplot3[x,
                                                                           y])

for xp in range(0, no_points1):
#****************************

#initialise comet box path
com_box_path = np.zeros((2*sum(np.shape(ra))-3,2),dtype =float)
len1 = np.shape(ra)[0]; len0 = np.shape(ra)[1]
com_box_path[0:len0,0] = ra[0,:]
com_box_path[0:len0,1] = dec[0,:]
com_box_path[len0:len0+len1-1,0] = ra[1:,-1]
com_box_path[len0:len0+len1-1,1] = dec[1:,-1]
com_box_path[len0+len1-1:2*len0+len1-2,0] = ra[-1,-2::-1]
com_box_path[len0+len1-1:2*len0+len1-2,1] = dec[-1,-2::-1]
com_box_path[2*len0+len1-2:2*len0+2*len1-3,0] = ra[-2::-1,0]
com_box_path[2*len0+len1-2:2*len0+2*len1-3,1] = dec[-2::-1,0]
com_Path = mplPath.Path(com_box_path)   

comlocra = ra2xpix(comobs[:,5], border, pixwidth, rafmin, scale)
comlocdec = dec2ypix(comobs[:,6], border, pixheight, decmin, scale)

decgoodlocs = np.where((comlocdec < (imgheight-border*1.5)) & (comlocdec > border*1.5))[0]
ragoodlocs = np.where((comlocra < (imgwidth-border*2.5)) & (comlocra > border*1.5))[0]
goodlocs = np.intersect1d(decgoodlocs,ragoodlocs)

traj_pix = w.wcs_world2pix(comobs[goodlocs,5:7],0)
locs_1 = np.where((traj_pix[:,1]>0)&(traj_pix[:,0]>0))
traj_pix = traj_pix[locs_1[0],:]
locs_2 = np.where((traj_pix[:,0]<(colr.shape[0]-1))&(traj_pix[:,1]<(colr.shape[1]-1)))
traj_pix = traj_pix[locs_2[0],:]

traj_pix_floor = np.floor(traj_pix).astype(int)
traj_pix_round = np.round(traj_pix).astype(int)
        len1 = np.shape(ra)[0]
        len0 = np.shape(ra)[1]
        com_box_path[0:len0, 0] = ra[0, :]
        com_box_path[0:len0, 1] = dec[0, :]
        com_box_path[len0:len0 + len1 - 1, 0] = ra[1:, -1]
        com_box_path[len0:len0 + len1 - 1, 1] = dec[1:, -1]
        com_box_path[len0 + len1 - 1:2 * len0 + len1 - 2, 0] = ra[-1, -2::-1]
        com_box_path[len0 + len1 - 1:2 * len0 + len1 - 2, 1] = dec[-1, -2::-1]
        com_box_path[2 * len0 + len1 - 2:2 * len0 + 2 * len1 - 3,
                     0] = ra[-2::-1, 0]
        com_box_path[2 * len0 + len1 - 2:2 * len0 + 2 * len1 - 3,
                     1] = dec[-2::-1, 0]
        com_Path = mplPath.Path(com_box_path)

        #comet
        comlocra = ra2xpix(comobs[:, 5], border, pixwidth, rafmin, scale)
        comlocdec = dec2ypix(comobs[:, 6], border, pixheight, decmin, scale)

        decgoodlocs = np.where((comlocdec < (imgheight - border * 1.5))
                               & (comlocdec > border * 1.5))[0]
        ragoodlocs = np.where((comlocra < (imgwidth - border * 2.5))
                              & (comlocra > border * 1.5))[0]
        goodlocs = np.intersect1d(decgoodlocs, ragoodlocs)

        for o in range(0, np.size(goodlocs) - 1):
            ocel = goodlocs[o]
            d.line([(comlocra[ocel], comlocdec[ocel]),
                    (comlocra[ocel + 1], comlocdec[ocel + 1])],
                   fill=(255, 0, 0, 255))

        #venus
Ejemplo n.º 7
0
            np.round((np.clip(colours, 1e-20, 999999999) - low) * grad), 0,
            255)).astype(int)
        colcg = (np.clip(
            np.round((np.clip(colours, 1e-20, 999999999) - low) * grad), 0,
            255)).astype(int)
        colcb = (np.clip(
            np.round((np.clip(colours, 1e-20, 999999999) - low) * grad), 0,
            255)).astype(int)

        imagemask = np.ones_like(colours)[:-1, :-1]

        non_zeros_0 = np.where(imagemask == 1)[0]
        non_zeros_1 = np.where(imagemask == 1)[1]
        no_points = non_zeros_0.size

        rp = ra2xpix(ra_m, border, pixwidth, trafmin, scale)
        dp = dec2ypix(dec, border, pixheight, tdecmin, scale)

        for xp in range(0, no_points):
            x = non_zeros_0[xp]
            y = non_zeros_1[xp]
            plotpixel2(d, x, y, rp, dp, colcr[x, y], colcg[x, y], colcb[x, y])

        if 'S' in obsloc:
            [ctime,
             uncertainty_range_exists] = image_time_stereo(image_basename)

        comcel = np.where(
            abs(obsveceq[:, 0] - ctime.jd) == abs(obsveceq[:, 0] -
                                                  ctime.jd).min())[0][0]
Ejemplo n.º 8
0
def plot_orbit_ecliptic(comobs, comveceq, obsveceq, axisdata, d, comcel,
                        trajfill, ra_img_lower, ra_img_higher, border,
                        pixwidth, rafmin, scale, pixheight, decmin, fnt,
                        featur_fill, con_in_image, fixwrapsbool):

    #find rough cell range of traj from observer data
    obsraloc = np.where((comobs[:,5] > ra_img_lower) \
    & (comobs[:,5] < ra_img_higher))[0]
    obsdecloc = np.where((comobs[:,6] > axisdata[8]) \
    & (comobs[:,6] < axisdata[9]))[0]
    trajrough = np.intersect1d(obsraloc, obsdecloc)

    if trajrough.size != 0:

        #use this to calculate ra and dec of comet for a purposely oversized range
        vno = 0
        vext = int(np.size(trajrough))
        vtraj = np.empty((np.size(trajrough) + 2 * vext - 1, 11), dtype=float)
        tcellmax = min(trajrough[-1] + vext, np.shape(comveceq)[0])
        for tcell in range(trajrough[0] - vext, tcellmax):
            vtemp = comveceq[tcell, 6:9] - obsveceq[comcel, 6:9]
            ptemp = ecliptic_pos2radec(vtemp, fixwrapsbool)
            vtraj[vno, 0] = ptemp[0]
            vtraj[vno, 1] = ptemp[1]
            vtraj[vno, 4] = tcell
            vtraj[vno, 5] = tcell + round(
                np.linalg.norm(vtemp) * 8.316746397269274)
            vtraj[vno, 6:11] = comveceq[tcell, 1:6]
            vno += 1

        #use these ra and dec values to slim data down to within image borders
        trajrange = np.intersect1d(
            np.intersect1d(
                np.where(vtraj[:, 0] < ra_img_higher)[0],
                np.where(vtraj[:, 0] > ra_img_lower)[0]),
            np.intersect1d(
                np.where(vtraj[:, 1] < axisdata[9])[0],
                np.where(vtraj[:, 1] > axisdata[8])[0]))
        vtraj = vtraj[trajrange[0]:trajrange[-1], :]

        #find relevant cell in vtraj and comveceq accounting for LT
        if con_in_image == True:
            vtrajcel = np.where(abs(vtraj[:, 5] - comcel) < 1e-4)[0][0]
            ltcomcel = int(vtraj[vtrajcel, 4])
        else:
            ltcomcel = None
            vtrajcel = None

        #convert to ra and dec, and plot
        vtraj[:, 2] = ra2xpix(vtraj[:, 0], border, pixwidth, rafmin, scale)
        vtraj[:, 3] = dec2ypix(vtraj[:, 1], border, pixheight, decmin, scale)
        for ta in range(0, (np.shape(vtraj)[0] - 1)):
            d.line([(vtraj[ta,2],vtraj[ta,3]),(vtraj[ta+1,2],vtraj[ta+1,3])],\
            fill = trajfill)

        #plot the path
        d.text((2*border + pixwidth + 30,border + 200), \
        "Orbital Path:",font=fnt, fill= featur_fill)
        d.line([(2 * border + pixwidth + 30, border + 230),
                (2 * border + pixwidth + 170, border + 230)],
               fill=trajfill)

    else:
        ltcomcel = None
        vtraj = None
        vtrajcel = None

    return ltcomcel, vtraj, vtrajcel