Example #1
0
 def correctbaseline(self, nameofstation):
     timeofsunmax = self.simtofmax / 100  # time in HH.hh (13.66 = 13h40) instead of HHhh (1366 = 13h40)
     #        print 'timeofsunmax = ' , timeofsunmax
     #        print 't1 = ' , int(timeofsunmax - 2),  ' ' ,  int(np.modf(timeofsunmax - 2)[0]*60)
     #        t1 = utils.doytodate(self.day.year,self.day.day,int(timeofsunmax - 2), int(np.modf(timeofsunmax - 2)[0]*60))
     #        t2 = utils.doytodate(self.day.year,self.day.day,int(timeofsunmax + 2), int(np.modf(timeofsunmax + 2)[0]*60))
     t1 = utils.doytodate(self.day.year,
                          self.day.timetuple().tm_yday,
                          int(timeofsunmax - 4),
                          int(np.modf(timeofsunmax - 4)[0] * 60))
     t2 = utils.doytodate(self.day.year,
                          self.day.timetuple().tm_yday,
                          int(timeofsunmax + 4),
                          int(np.modf(timeofsunmax + 4)[0] * 60))
     nsradio = self.datasim.data[(self.datasim.timedata < t1) |
                                 (self.datasim.timedata > t2)]
     nstemp = self.datasim.tempLL[(self.datasim.timedata < t1) |
                                  (self.datasim.timedata > t2)]
     ## subtract the mean of the time when no sun is present in the data
     radio = self.datasim.data - np.mean(nsradio)
     temp = self.datasim.tempLL - np.mean(nstemp)
     nstemp = nstemp - np.mean(nstemp)
     ## get the file with temperature fit result
     fitfile = constant.tempfitfolder + '/tempfit_' + nameofstation + '.npy'
     #        fitfile = constant.tempfitfolder + '/tempfit_'+nameoflist[:-4] + '.npy'
     tempfit = np.load(fitfile)
     pfit = np.poly1d(tempfit)
     radio = radio - pfit(temp)
     ## baseline corrected
     nsradioc = nsradio - np.mean(nsradio)
     nsradioc = nsradioc - pfit(nstemp)
     self.pointuncert = np.std(nsradioc)
     self.cbaseline = radio
Example #2
0
            #            print datafilename
            if os.path.isfile(datafilename):
                datafile = open(datafilename, 'rb')
            else:
                continue
            thedata = pickle.load(datafile)
            simfile = constant.simresultfolder + str(
                stid) + '/exptemp_' + stname + '_' + str(t) + '_' + str(
                    p) + '_' + str(y) + '_' + str(d) + '.txt'
            [h, m, temp] = utils.readtempfile(simfile)
            sec = 3600 * h + 60 * m
            hour = h * 100 + m * (100. / 60.)
            thedata.sim = temp
            thedata.timesim = hour

            day = utils.doytodate(y, d)
            an = analyse.Analyse(day, 0, 0, thedata)
            simparam = an.getsimparam()

            an.correctbaseline(stname)
            signalwindow = 4
            fitresult = an.fitdata2(signalwindow)
            [fithourarray, fitradio] = an.getdataforfit(4)
            if (fitresult.success == True):
                #                 fig = plt.figure()
                #                 plt.plot(fithourarray,fitradio)
                #                 plt.plot(fithourarray, fitresult.best_fit, 'r-')
                #                 plt.gca().text(np.mean(fithourarray),np.mean(fitradio), r'$\frac{\chi^2}{ndl} = $' +str(fitresult.redchi), fontsize=15)
                #                saving part:
                outname = constant.datafit2folder + str(
                    stid) + '/fit2_' + stname + '_' + str(t) + '_' + str(
Example #3
0
############################
## load the root file     ##
############################
filename = 'alldata.root'
file = constant.datafolder + 'GIGADuck/' + filename

data = dataset.Dataset(file)
data.loaddata()
data = data.getnewdatawithid(stid)
data.selectleafs()

outfolder = constant.dataresultfolder
years = [2015, 2016, 2017]
for y in years:
    for d in range(1, constant.doy[y] + 1, 1):
        sdatelim1 = utils.doytodate(y, d, hour=3)
        deltat = datetime.timedelta(1)
        sdatelim2 = sdatelim1 + deltat
        cond = np.where((data.date > sdatelim1) & (data.date < sdatelim2))
        daydataset = data.getnewdatasetcond(cond)

        if (len(daydataset.date) == 0):
            continue
        ddata = daydata.Daydata('simpledata', y, d, daydataset.date,
                                daydataset.radio, daydataset.tempLL,
                                daydataset.humLL, [], [])

        #######################################
        ## save in pkl format the daily data ##
        #######################################
        outf = outfolder + str(stid)
Example #4
0
    deltaphis = deltaphis.astype(int)
    deltaphis = np.unique(deltaphis)
    for delp in deltaphis:
        newp = centerphi + delp
        #        befantsetup = ttime.time()
        ant.antennageo = (newt,newp)
#        ant.antennageo = (delt,delp)
        ant.setrotationmatrix()
#        afterantsetup = ttime.time()
#        print 'ant setup =  ', afterantsetup - befantsetup

        print ant.antennageo
        for y,d in zip(goodyear,goodday):
            y = int(y)
            d = int(d)
            date = utils.doytodate(y,d)
            totsunflux = sflux.getflux(y,d)
            pos = sflux.getposition(y,d)
            sec = np.linspace(0,24*60*60,len(pos[0]))
            posplot = utils.transformsunpos(pos[0],pos[1])
            if detector=='dmx':
                newpos = utils.transformsunposdmx(pos[0],pos[1])
            else:
#                beftransfo = ttime.time()
                newpos = utils.transformsunpos(pos[0],pos[1])
                newpos = utils.transformtrajectory(newpos[0],newpos[1],ant.rotationmatrix)
#                aftertransfo = ttime.time()
#                print 'transfi =  ', aftertransfo - beftransfo
            max = -10
            daytemp = np.array([])
            hourarray = np.array([])
Example #5
0
 datafilename = outfolder + '/data_' + str(int(y)) + '_' + str(
     int(d)) + '.pkl'
 datafilenameref = outfolderref + '/data_' + str(int(y)) + '_' + str(
     int(d)) + '.pkl'
 if os.path.isfile(datafilename) == False or os.path.isfile(
         datafilenameref) == False:
     continue
 else:
     print 'aqui !'
     datafile = open(datafilename, 'rb')
     datafileref = open(datafilenameref, 'rb')
     thedata = pickle.load(datafile)
     thedataref = pickle.load(datafileref)
     time = thedata.timedata
     timeofsunmax = constant.exptime[stid]
     t1 = utils.doytodate(int(y), int(d), int(timeofsunmax - 2),
                          int(np.modf(timeofsunmax - 2)[0]))
     t2 = utils.doytodate(int(y), int(d), int(timeofsunmax + 2),
                          int(np.modf(timeofsunmax + 2)[0]))
     radio = thedata.data[(thedata.timedata < t1) | (thedata.timedata > t2)]
     radior = thedataref.data[(thedata.timedata < t1) |
                              (thedata.timedata > t2)]
     temp = thedata.tempLL[(thedata.timedata < t1) |
                           (thedata.timedata > t2)]
     radio = radio - np.mean(radio)
     radior = radior - np.mean(radior)
     temp = temp - np.mean(temp)
     nosuntime = np.append(
         nosuntime, time[(thedata.timedata < t1) | (thedata.timedata > t2)])
     nosunradio = np.append(nosunradio, radio)
     nosunradioref = np.append(nosunradioref, radior)
     nosuntemp = np.append(nosuntemp, temp)