Exemple #1
0
    def secularacceleration(self,times,interval=0.5,phiv=scipy.linspace(0.0,scipy.pi*2,100),thetav=scipy.linspace(0.01,scipy.pi-0.01,100),rparam=1.0):
        lowt=times-numpy.array(interval)
        hight=times+numpy.array(interval)

        timepairs=[(l,h,t) for l,h,t in zip(lowt,hight,times) if (l >= min(self.years) and h <= max(self.years))]
        validtimes=[p[2] for p in timepairs]

        g_high,h_high=self.interpolated([p[1] for p in timepairs])
        g_current,h_current=self.interpolated([p[2] for p in timepairs])
        g_low,h_low=self.interpolated([p[0] for p in timepairs])

        accs=[]

        for p,i in zip(timepairs,range(len(timepairs))):

            highx,highy,highz=xyzfieldv(g_high[i],h_high[i],phiv,thetav,rparam)
            lowx,lowy,lowz=xyzfieldv(g_low[i],h_low[i],phiv,thetav,rparam)
            currentx,currenty,currentz=xyzfieldv(g_current[i],h_current[i],phiv,thetav,rparam)

            accx=(lowx-2*currentx+highx)/((p[2]-p[0])*(p[1]-p[2]))
            accy=(lowy-2*currenty+highy)/((p[2]-p[0])*(p[1]-p[2]))
            accz=(lowz-2*currentz+highz)/((p[2]-p[0])*(p[1]-p[2]))

            accs.append((accx,accy,accz))

        return validtimes,numpy.array(accs)
Exemple #2
0
    def field_at_location(self, lat, lon, times=None, field="f", rparam=1.0):

        if times == None:
            times=numpy.array(self.years)

        thetav=numpy.array([scipy.pi/2-numpy.deg2rad(lat)])
        phiv=numpy.array([numpy.deg2rad(lon)])

        if field == "f":

            xyz = numpy.zeros((len(times),3))
            g,h=self.interpolated(times)

            for t,i in zip(times,range(len(times))):
                xyz[i,:]=numpy.array(xyzfieldv(g[i],h[i],phiv,thetav,rparam))
            return times, xyz[:,0], xyz[:,1], xyz[:,2]

        elif field == "s":

            vtimes,secular=self.secularvariation(times,interval=0.5,phiv=phiv,thetav=thetav)
            return vtimes, secular[:,0], secular[:,1], secular[:,2]

        elif field == "a":

            vtimes,acc=self.secularacceleration(times,interval=0.5,phiv=phiv,thetav=thetav)
            return vtimes, acc[:,0], acc[:,1], acc[:,2]

        else: raise Exception("you did a bad thing :(")
Exemple #3
0
    def secularvariation(self,times,interval=0.5,phiv=scipy.linspace(0.0,scipy.pi*2,100),thetav=scipy.linspace(0.01,scipy.pi-0.01,100),rparam=1.0):
        lowt=times-numpy.array(interval)
        hight=times+numpy.array(interval)

        timepairs=[(l,h,t) for l,h,t in zip(lowt,hight,times) if (l >= min(self.years) and h <= max(self.years))]
        validtimes=[p[2] for p in timepairs]

        g_high,h_high=self.interpolated([p[1] for p in timepairs])
        g_low,h_low=self.interpolated([p[0] for p in timepairs])

        diffs=[]

        for p,i in zip(timepairs,range(len(timepairs))):

            highx,highy,highz=xyzfieldv(g_high[i],h_high[i],phiv,thetav,rparam)
            lowx,lowy,lowz=xyzfieldv(g_low[i],h_low[i],phiv,thetav,rparam)

            diffx=(highx-lowx)/(p[1]-p[0])
            diffy=(highy-lowy)/(p[1]-p[0])
            diffz=(highz-lowz)/(p[1]-p[0])

            diffs.append((diffx,diffy,diffz))

        return validtimes,numpy.array(diffs)