Beispiel #1
0
                for numspec in range(len(yobs)):
                    cc_numspec = []
                    for seg_num in range(int(segment)):
                        y_temp_order = h5f_temp[
                            str(ccd) + "vmr-" + str(vmr) + "-order-" +
                            str(order) + "-segment-" +
                            str(seg_num
                                )][:]  #Loading template of vmr, v= -55., 355
                        low_lim = int(((seg_num) / segment) * len(yobs[0]))
                        up_lim = int(((seg_num + 1.) / segment) * len(yobs[0]))

                        fluxsegment = yobs[numspec][low_lim:up_lim]

                        cc_each_seg = []
                        for rv in range(len(drvs)):
                            cc_rv = crossco(fluxsegment, y_temp_order[rv])
                            cc_each_seg.append(cc_rv)
                        cc_numspec.append(np.array(cc_each_seg))
                    cc_numspec = np.array(
                        cc_numspec)[~np.isnan(np.mean(cc_numspec, axis=1))]
                    cc_numspec_SA = np.mean(cc_numspec, axis=0)
                    cc_order_SA[numspec] = cc_numspec_SA
                cc_svd_collect_SA.append(cc_order_SA)
            cc_map_full_SA.append(cc_svd_collect_SA)
        h5f_cc.create_dataset(
            str(ccd) + "_cc_vmr_" + str(vmr),
            data=cc_map_full_SA)  #Writing the template of the specific vmr
#    h5f_reduced.close()
h5f_reduced.close()
h5f_cc.close()
h5f_temp.close()
        for var in tqdm(range(len_sv),ascii="True",desc=str(vari)+"="+str(va)+" R"+str(varname)):
            cc_svd_collect=[] #Different SV are saved in this matrix                       
            for order in tqdm (range(1,len_order),ascii="True",desc="Order"):
#                y_temp_order=h5f_temp[str(ccd)+"-vmr-"+str(va)+"-order-"+str(order)][:]
                yobs=h5f_reduced[str(ccd)+"-flux"+str(vari)+"-"+str(va)+"-order-"+str(order)+"sysrem"][:][var]
#                yobs=h5f_reduced[str(ccd)+"-flux-"+str(vari)+"-"+str(va)+"-order-"+str(order)+"sysrem"][:][var]
                y_temp_order=h5f_temp[str(ccd)+"-vmr-9-order-"+str(order)][:]
#                yobs= h5f_reduced[str(ccd)+"-flux-"+str(vari)+"-7-order-"+str(order)+str(varname)+"-"+str(var+1)][:]
                for filenum in range (len(yobs)):
                    sm = pyasl.smooth(yobs[filenum], 25, 'flat')
                    sm1 = pyasl.smooth(sm, 51, 'flat')
                    yobs[filenum]=(yobs[filenum]+1.)/(sm1+1.)-1.
                std_frames=[]
                std_pix=[]
                for wvbin in range (len(yobs[1])):
                    std_pix.append(np.std(yobs[:,wvbin]))
                for filenum in range (len(yobs)):
                    std_frames.append(np.std(yobs[filenum,:]))
                std_frames=np.array(std_frames,dtype="float")
                yobs=divstd_prime(yobs,std_pix,std_frames)
                cc_order=np.zeros((len(yobs),len(drvs)),dtype="float")
                for numspec in range(len(yobs)):
                    for rv in range(len(drvs)):
                        cc_order[numspec][rv]=crossco(yobs[numspec],y_temp_order[rv])
#                        cc_order[numspec][rv]=cc_sp(yobs[numspec],y_temp_order[rv])
                cc_svd_collect.append(cc_order)
            cc_map_full.append(np.array(cc_svd_collect))
        h5f_cc.create_dataset(str(ccd)+"_cc_"+str(vari)+"_"+str(va), data= np.array(cc_map_full)) #Writing the template of the specific vmr
h5f_cc.close()
h5f_reduced.close()