def _open_np(pathfileext, Ves=None,
             ReplacePath=None, out='full', Verb=False, Print=True):

    if 'TFG' in pathfileext:
        import tofu.geom as tfg
    elif 'TFD' in pathfileext:
        import tofu.data as tfd
    #elif 'TFEq' in pathfileext:
    #    import tofu.Eq as tfEq
    #elif 'TFM' in pathfileext:
    #    import tofu.mesh as TFM
    #elif 'TFMC' in pathfileext:
    #    import tofu.matcomp as TFMC
    #elif 'TFT' in pathfileext:
    #    import tofu.treat as tft
    #elif 'TFI' in pathfileext:
    #    import tofu.inv as TFI

    try:
        Out = np.load(pathfileext,mmap_mode=None)
    except UnicodeError:
        Out = np.load(pathfileext,mmap_mode=None, encoding='latin1')
    Id = ID(fromdict=Out['Id'].tolist())
    if out=='Id':
        return Id

    if Id.Cls == 'Ves':
        Lim = None if Out['Lim'].tolist() is None else Out['Lim']
        obj = tfg.Ves(Id, Out['Poly'], Lim=Lim, Type=Id.Type,
                      Clock=bool(Out['Clock']),
                      arrayorder=str(Out['arrayorder']),
                      Sino_RefPt=Out['Sino_RefPt'], Sino_NP=int(Out['Sino_NP']))

    elif Id.Cls == 'Struct':
        Lim = None if Out['Lim'].tolist() is None else Out['Lim']
        obj = tfg.Struct(Id, Out['Poly'], Type=Id.Type, Lim=Lim,
                         Clock=bool(Out['Clock']),
                         arrayorder=str(Out['arrayorder']),
                         mobile=Out['mobile'].tolist())

    elif Id.Cls in ['Rays','LOS','LOSCam1D','LOSCam2D']:
        Ves, LStruct = _tryloadVesStruct(Id, Print=Print)
        dobj = {'Id':Id._todict(), 'dchans':Out['dchans'].tolist(),
                'geom':Out['geom'].tolist(),
                'sino':Out['sino'].tolist()}
        if 'extra' in Out.keys():
            dobj['extra'] = Out['extra'].tolist()
        if Ves is None:
            dobj['Ves'] = None
        else:
            dobj['Ves'] = Ves._todict()
        if LStruct is None:
            dobj['LStruct'] = None
        else:
            dobj['LStruct'] = [ss._todict() for ss in LStruct]
        if Id.Cls=='Rays':
            obj = tfg.Rays(fromdict=dobj)
        elif Id.Cls=='LOSCam1D':
            obj = tfg.LOSCam1D(fromdict=dobj)
        elif Id.Cls=='LOSCam2D':
            obj = tfg.LOSCam2D(fromdict=dobj)

    elif Id.Cls in ['Data1D','Data2D']:
        dobj = {'Id':Id._todict(), 'Ref':Out['Ref'].tolist(),
                'dunits':Out['dunits'].tolist(), 'fft':Out['fft'].tolist(),
                'data0':Out['data0'].tolist(), 'CamCls':Out['CamCls'].tolist()}
        indt = None if Out['indt'].tolist() is None else Out['indt']
        indch = None if Out['indch'].tolist() is None else Out['indch']
        if Out['geom'].tolist() is None:
            geom = None
        else:
            if 'Cam' in Out['geom'][0]:
                LCam = [Open(ss)._todict() for ss in Out['geom']]
                geom = {'LCam':LCam}
            else:
                Ves = Open(Out['geom'][0])._todict()
                if len(Out['geom'])>1:
                    LStruct = [Open(ss)._todict() for ss in Out['geom'][1:]]
                else:
                    LStruct = None
                    geom = {'LCam':None, 'Ves':Ves, 'LStruct':LStruct}
        dobj['indt'] = indt
        dobj['indch'] = indch
        dobj['geom'] = geom
        if 'dMag' in Out.keys():
            dMag = Out['dMag'].tolist()
        else:
            dMag = None
        dobj['dMag'] = dMag
        if Id.Cls=='Data1D':
            obj = tfd.Data1D(fromdict=dobj)
        elif Id.Cls=='Data2D':
            obj = tfd.Data2D(fromdict=dobj)

    """
    elif Id.Cls == 'GLOS':
        Ves = _tryloadVes(Id)
        LLOS, IdLOS = [], Id.LObj['LOS']
        for ii in range(0,len(IdLOS['Name'])):
            Idl = _Id_recreateFromdict(Out['LIdLOS'][ii])
            ll = TFG.LOS(Idl, Du=(Out['LDs'][:,ii],Out['Lus'][:,ii]), Ves=Ves, Sino_RefPt=Out['Sino_RefPt'], arrayorder=str(Out['arrayorder']))
            LLOS.append(ll)
        obj = TFG.GLOS(Id, LLOS, Ves=Ves, Type=Id.Type, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, Sino_RefPt=Out['Sino_RefPt'], SavePath=Id.SavePath, arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']),
                       dtime=Id.dtime)

    elif Id.Cls == 'Lens':
        Ves = _tryloadVes(Id, Ves=Ves)
        obj = TFG.Lens(Id, Out['O'], Out['nIn'], Out['Rad'][0], Out['F1'][0], F2=Out['F2'][0], Type=Id.Type, R1=Out['R1'][0], R2=Out['R2'][0], dd=Out['dd'][0], Ves=Ves,
                Exp=Id.Exp, Clock=bool(Out['Clock']), Diag=Id.Diag, shot=Id.shot, arrayorder=str(Out['arrayorder']), SavePath=Id.SavePath, dtime=Id.dtime)

    elif Id.Cls == 'Apert':
        Ves = _tryloadVes(Id, Ves=Ves)
        obj = TFG.Apert(Id, Out['Poly'], Clock=bool(Out['Clock']), arrayorder=str(Out['arrayorder']), Ves=Ves, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, dtime=Id.dtime)

    elif Id.Cls == 'Detect':
        Ves = _tryloadVes(Id, Ves=Ves)
        if 'VesCalc'in Out.keys() and Out['VesCalc'][0]['SavePath'] is not None:
            VesCalc = Open(Out['VesCalc'][0]['SavePath']+Out['VesCalc'][0]['SaveName']+'.npz')
        else:
            VesCalc = None
        LOSprops, Sino, Span, Cone, SAng, Opt = Out['LOSprops'][0], Out['Sino'][0], Out['Span'][0], Out['Cone'][0], Out['SAng'][0], Out['Optics'][0]
        (SynthDiag,Res) = (Out['SynthDiag'][0],Out['Res'][0]) if out=='full' else _get_light_SynthDiag_Res()
        Optics = _tryLoadOpticsElseCreate(Id, Opt=Opt, Ves=Ves, Verb=Verb)

        Poly = Out['Poly'] if type(Optics) is list else dict(Rad=float(Out['Rad']),O=Out['BaryS'],nIn=Out['nIn'])
        obj = TFG.Detect(Id, Poly, Optics=Optics, Ves=Ves, VesCalc=VesCalc, Sino_RefPt=Sino['_Sino_RefPt'], CalcEtend=False, CalcSpanImp=False, CalcCone=False, CalcPreComp=False, Calc=True, Verb=Verb,
                         arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']))
        obj = _resetDetectAttr(obj, {'LOSprops':LOSprops, 'Sino':Sino, 'Span':Span, 'Cone':Cone, 'SAng':SAng, 'SynthDiag':SynthDiag, 'Res':Res, 'Optics':Opt})
        obj._LOS_NP = Out['LOSNP']
        if obj._SynthDiag_Done and obj._SynthDiag_Points is None:
            obj.set_SigPrecomp()

    elif Id.Cls == 'GDetect':
        LDetsave = list(Out['LDetsave'])
        LDet = []
        Ves = _tryloadVes(Id, Ves=Ves)
        if out=='light':
            SynthDiag, Res = _get_light_SynthDiag_Res()
        else:
            LDetSynthRes = Out['LDetSynthRes']
        for ii in range(0,len(LDetsave)):
            ddIdsave = _Id_recreateFromdict(LDetsave[ii]['Idsave'])
            if 'VesCalc'in LDetsave[ii].keys() and LDetsave[ii]['VesCalc'][0]['SavePath'] is not None:
                VesCalc = Open(LDetsave[ii]['VesCalc'][0]['SavePath']+LDetsave[ii]['VesCalc'][0]['SaveName']+'.npz')
            else:
                VesCalc = None
            LOSprops, Sino, Span, Cone, SAng, Opt = LDetsave[ii]['LOSprops'][0], LDetsave[ii]['Sino'][0], LDetsave[ii]['Span'][0], LDetsave[ii]['Cone'][0], LDetsave[ii]['SAng'][0], LDetsave[ii]['Optics'][0]
            if out=='full':
                SynthDiag, Res = LDetSynthRes[ii]['SynthDiag'][0], LDetSynthRes[ii]['Res'][0]
            Optics = _tryLoadOpticsElseCreate(ddIdsave, Opt=Opt, Ves=Ves, Verb=Verb)
            Poly = LDetsave[ii]['Poly'] if type(Optics) is list else dict(Rad=float(LDetsave[ii]['Rad']),O=LDetsave[ii]['BaryS'],nIn=LDetsave[ii]['nIn'])
            Sino_RefPt = None if Out['Sino_RefPt'].shape==() else Out['Sino_RefPt']
            dd = TFG.Detect(ddIdsave, Poly, Optics=Optics, Ves=Ves, VesCalc=VesCalc, Sino_RefPt=Sino_RefPt, CalcEtend=False, CalcSpanImp=False, CalcCone=False, CalcPreComp=False, Calc=True, Verb=Verb,
                            arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']))
            dd = _resetDetectAttr(dd, {'LOSprops':LOSprops, 'Sino':Sino, 'Span':Span, 'Cone':Cone, 'SAng':SAng, 'SynthDiag':SynthDiag, 'Res':Res, 'Optics':Opt})
            dd._LOS_NP = LDetsave[ii]['LOSNP']
            if dd._SynthDiag_Done and dd._SynthDiag_Points is None:
                dd.set_SigPrecomp()
            LDet.append(dd)
        obj = TFG.GDetect(Id, LDet, Type=Id.Type, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, dtime=Id.dtime, Sino_RefPt=Out['Sino_RefPt'], LOSRef=str(Out['LOSRef']),
                          arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']), SavePath=Id.SavePath)
        Res = Out['Res'][0] if out=='full' else Res
        for kk in Res.keys():
            setattr(obj,kk,Res[kk])

    elif Id.Cls=='Eq2D':
        Sep = [np.array(ss) for ss in Out['Sep'].tolist()]
        obj = tfEq.Eq2D(Id, Out['PtsCross'], t=Out['t'], MagAx=Out['MagAx'], Sep=Sep, rho_p=Out['rho_p'].tolist(), rho_t=Out['rho_t'].tolist(), surf=Out['surf'].tolist(), vol=Out['vol'].tolist(),
                        q=Out['q'].tolist(), jp=Out['jp'].tolist(), pf=Out['pf'].tolist(), tf=Out['tf'].tolist(), theta=Out['theta'].tolist(), thetastar=Out['thetastar'].tolist(),
                        BTX=Out['BTX'].tolist(), BRY=Out['BRY'].tolist(), BZ=Out['BZ'].tolist(), Ref=str(Out['Ref']))

    elif Id.Cls=='Mesh1D':
        obj = TFM.Mesh1D(Id, Out['Knots'])

    elif Id.Cls=='Mesh2D':
        obj = TFM.Mesh2D(Id, [Out['Knots'][0],Out['Knots'][1]])
        obj = TFM.Mesh2D(Id, Knots=obj, ind=Out['IndBg'])
        for ii in range(0,len(Out['SubMinds'])):
            obj.add_SubMesh(Name=Out['SubMinds'][ii]['Name'], ind=Out['SubMinds'][ii]['ind'])

    elif Id.Cls=='Metric1D':
        obj = TFM.Metric1D(Id)

    elif Id.Cls=='Metric2D':
        obj = TFM.Metric2D(Id)


    elif Id.Cls in 'BF2D':
        IdMesh = ID(str(Out['IdMesh'][0]), str(Out['IdMesh'][1]), SaveName=str(Out['IdMesh'][2]), SavePath=str(Out['IdMesh'][3]), dtime=Out['dtimeMesh'][0], dtFormat=str(Out['IdMesh'][4]))
        M2 = TFM.Mesh2D(IdMesh, Knots=[Out['KnotsR'],Out['KnotsZ']])
        M2bis = TFM.Mesh2D(IdMesh,Knots=M2,Ind=Out['Ind'])
        obj = TFM.BF2D(Id, M2bis, int(Out['Deg'][0]))
    elif Id.Cls=='GMat2D':
        import ToFu_MatComp as TFMC
        import scipy.sparse as scpsp
        Id.set_LObj(open_np_IdObj(['Ves','BF2D','Detect'], [Out['Ves'],Out['BF2'],Out['LDetect']], [Out['VesUSR'],Out['BF2USR'],Out['LDetectUSR']]))
        Mat = scpsp.csr_matrix((Out['Matdata'], Out['Matind'], Out['Matindpr']), shape=Out['Matshape'])
        MatLOS = scpsp.csr_matrix((Out['MatLOSdata'], Out['MatLOSind'], Out['MatLOSindpr']), shape=Out['MatLOSshape'])
        obj = TFMC.GMat2D(Id, None, None, Mat=None, indMat=None, MatLOS=None, Calcind=False, Calc=False, CalcLOS=False)
        obj._init_CompParam(Mode=str(Out['CompParamStr'][0]), epsrel=Out['CompParamVal'][0], SubP=Out['CompParamVal'][1], SubMode=str(Out['CompParamStr'][1]), SubTheta=Out['CompParamVal'][2], SubThetaMode=str(Out['CompParamStr'][2]), Fast=bool(Out['CompParamVal'][-1]), SubPind=Out['CompParamVal'][3], ModeLOS=str(Out['CompParamStr'][3]), epsrelLOS=Out['CompParamVal'][4], SubPLOS=Out['CompParamVal'][5], SubModeLOS=str(Out['CompParamStr'][4]))
        obj._BF2 = None
        obj._BF2_Deg = int(Out['BF2Par'][0])
        obj._BF2_NCents = int(Out['BF2Par'][2])
        obj._BF2_NFunc = int(Out['BF2Par'][1])
        obj._Ves = None
        obj._LD = None
        obj._LD_nDetect = int(Out['LD_nD'])
        obj._set_indMat(indMat=Out['indMat'], Verb=False)
        obj._set_MatLOS(MatLOS=MatLOS, Verb=False)
        obj._set_Mat(Mat=Mat, Verb=False)



    elif Id.Cls=='PreData':
        LIdDet = Id.get_LObjasLId('Detect') if 'Detect' in Id.LObj.keys() else None
        Init, Update = Out['Init'][0], Out['Update'][0]
        obj = tft.PreData(Init['data'], Id=Id, t=Init['t'], Chans=Init['Chans'], DtRef=Init['DtRef'], LIdDet=LIdDet)
        obj.set_Dt(Update['Dt'], Calc=False)
        obj.set_Resamp(t=Update['Resamp_t'], f=Update['Resamp_f'], Method=Update['Resamp_Method'], interpkind=Update['Resamp_interpkind'], Calc=False)
        obj.Out_add(indOut=Update['indOut'], Calc=False)
        obj.Corr_add(indCorr=Update['indCorr'], Calc=False)
        obj.interp(lt=Update['interp_lt'], lNames=Update['interp_lNames'], Calc=False)
        obj.substract_Dt(tsub=Update['Subtract_tsub'], Calc=False)
        obj.set_fft(Calc=True, **Update['FFTPar'])
        if not Update['PhysNoiseParam'] is None:
            Method = 'svd' if 'Modes' in Update['PhysNoiseParam'].keys() else 'fft'
            obj.set_PhysNoise(**Update['PhysNoiseParam'].update({'Method':Method}))


        #Id.set_LObj(open_np_IdObj(['Detect'],[Out['LDetect']], [Out['LDetectUSR']]))
        #obj = TFT.PreData(Id=Id, shot=int(Out['shot']), DLPar=Out['DLPar'].item(), Exp=str(Out['StrPar'][0]), Dt=list(Out['Dt']), DtMargin=float(Out['DtMarg']), MovMeanfreq=float(Out['MovMeanfreq']), Resamp=bool(Out['Resamp']),
        #        interpkind=str(Out['StrPar'][1]), indOut=Out['indOut'], indCorr=Out['indCorr'], lt=Out['interp_lt'], lNames=Out['interp_lN'].tolist(), Test=True)
        #if not Out['PhysNoise'].item() is None:
        #    obj.set_PhysNoise(Deg=int(Out['NoiseMod'].item()['Deg']), Nbin=int(Out['NoiseMod'].item()['Nbin']), LimRatio=float(Out['NoiseMod'].item()['LimRatio']), **Out['PhysNoise'].item()['Param'])


    elif Id.Cls=='Sol2D':
        Id.set_LObj(open_np_IdObj(['PreData','GMat2D','BF2D'],[Out['PreData'], Out['GMat2D'], Out['BF2D']], [Out['PreDataUSR'],Out['GMatUSR'],Out['BF2DUSR']]))
        GMSaveName = Id.LObj['GMat2D']['SaveName'][0]
        try:
            GMat = Open(Id.LObj['GMat2D']['SavePath'][0]+GMSaveName+'.npz')
        except Exception:
            GMSaveName = GMSaveName[:GMSaveName.index('All_')+4]+'sh'+GMSaveName[GMSaveName.index('All_')+4:]
            GMat = Open(Id.LObj['GMat2D']['SavePath'][0]+GMSaveName+'.npz')
        obj = TFI.Sol2D(Id, PreData=None, GMat=GMat, InvParam=Out['InvParam'].item(), SVesePreData=False, SVeseGMat=True, SVeseBF=True)
        obj._PreData = None
        obj._GMat = obj.GMat.get_SubGMat2D(Val=list(Out['LNames']), Crit='Name',InOut='In')
        obj._shot = int(Out['shot'])
        try:
            obj._LNames = Out['LNames'].tolist()
        except Exception:
            obj._LNames = obj.PreData.In_list()
        obj._run = bool(Out['Run'])
        if bool(Out['Run']):
            obj._LOS = bool(Out['LOS'])
            obj._t, obj._data = Out['t'], Out['data']
            obj._Coefs, obj._sigma = Out['Coefs'], Out['sigma']
            obj._Mu, obj._Chi2N, obj._R, obj._Nit = Out['Mu'], Out['Chi2N'], Out['R'], Out['Nit']
            obj._Spec = list(Out['Spec'])
            obj._timing = Out['t2']
            obj._PostTreat = list(Out['PostTreat'])
    """
    return obj
elif Id.Cls == 'GLOS':
        Ves = _tryloadVes(Id)
        LLOS, IdLOS = [], Id.LObj['LOS']
        for ii in range(0,len(IdLOS['Name'])):
            Idl = _Id_recreateFromdict(Out['LIdLOS'][ii])
            ll = TFG.LOS(Idl, Du=(Out['LDs'][:,ii],Out['Lus'][:,ii]), Ves=Ves, Sino_RefPt=Out['Sino_RefPt'], arrayorder=str(Out['arrayorder']))
            LLOS.append(ll)
        obj = TFG.GLOS(Id, LLOS, Ves=Ves, Type=Id.Type, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, Sino_RefPt=Out['Sino_RefPt'], SavePath=Id.SavePath, arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']),
                       dtime=Id.dtime)

    elif Id.Cls == 'Lens':
        Ves = _tryloadVes(Id, Ves=Ves)
        obj = TFG.Lens(Id, Out['O'], Out['nIn'], Out['Rad'][0], Out['F1'][0], F2=Out['F2'][0], Type=Id.Type, R1=Out['R1'][0], R2=Out['R2'][0], dd=Out['dd'][0], Ves=Ves,
                Exp=Id.Exp, Clock=bool(Out['Clock']), Diag=Id.Diag, shot=Id.shot, arrayorder=str(Out['arrayorder']), SavePath=Id.SavePath, dtime=Id.dtime)

    elif Id.Cls == 'Apert':
        Ves = _tryloadVes(Id, Ves=Ves)
        obj = TFG.Apert(Id, Out['Poly'], Clock=bool(Out['Clock']), arrayorder=str(Out['arrayorder']), Ves=Ves, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, dtime=Id.dtime)

    elif Id.Cls == 'Detect':
        Ves = _tryloadVes(Id, Ves=Ves)
        if 'VesCalc'in Out.keys() and Out['VesCalc'][0]['SavePath'] is not None:
            VesCalc = Open(Out['VesCalc'][0]['SavePath']+Out['VesCalc'][0]['SaveName']+'.npz')
        else:
            VesCalc = None
        LOSprops, Sino, Span, Cone, SAng, Opt = Out['LOSprops'][0], Out['Sino'][0], Out['Span'][0], Out['Cone'][0], Out['SAng'][0], Out['Optics'][0]
        (SynthDiag,Res) = (Out['SynthDiag'][0],Out['Res'][0]) if out=='full' else _get_light_SynthDiag_Res()
        Optics = _tryLoadOpticsElseCreate(Id, Opt=Opt, Ves=Ves, Verb=Verb)

        Poly = Out['Poly'] if type(Optics) is list else dict(Rad=float(Out['Rad']),O=Out['BaryS'],nIn=Out['nIn'])
        obj = TFG.Detect(Id, Poly, Optics=Optics, Ves=Ves, VesCalc=VesCalc, Sino_RefPt=Sino['_Sino_RefPt'], CalcEtend=False, CalcSpanImp=False, CalcCone=False, CalcPreComp=False, Calc=True, Verb=Verb,
                         arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']))
        obj = _resetDetectAttr(obj, {'LOSprops':LOSprops, 'Sino':Sino, 'Span':Span, 'Cone':Cone, 'SAng':SAng, 'SynthDiag':SynthDiag, 'Res':Res, 'Optics':Opt})
        obj._LOS_NP = Out['LOSNP']
        if obj._SynthDiag_Done and obj._SynthDiag_Points is None:
            obj.set_SigPrecomp()

    elif Id.Cls == 'GDetect':
        LDetsave = list(Out['LDetsave'])
        LDet = []
        Ves = _tryloadVes(Id, Ves=Ves)
        if out=='light':
            SynthDiag, Res = _get_light_SynthDiag_Res()
        else:
            LDetSynthRes = Out['LDetSynthRes']
        for ii in range(0,len(LDetsave)):
            ddIdsave = _Id_recreateFromdict(LDetsave[ii]['Idsave'])
            if 'VesCalc'in LDetsave[ii].keys() and LDetsave[ii]['VesCalc'][0]['SavePath'] is not None:
                VesCalc = Open(LDetsave[ii]['VesCalc'][0]['SavePath']+LDetsave[ii]['VesCalc'][0]['SaveName']+'.npz')
            else:
                VesCalc = None
            LOSprops, Sino, Span, Cone, SAng, Opt = LDetsave[ii]['LOSprops'][0], LDetsave[ii]['Sino'][0], LDetsave[ii]['Span'][0], LDetsave[ii]['Cone'][0], LDetsave[ii]['SAng'][0], LDetsave[ii]['Optics'][0]
            if out=='full':
                SynthDiag, Res = LDetSynthRes[ii]['SynthDiag'][0], LDetSynthRes[ii]['Res'][0]
            Optics = _tryLoadOpticsElseCreate(ddIdsave, Opt=Opt, Ves=Ves, Verb=Verb)
            Poly = LDetsave[ii]['Poly'] if type(Optics) is list else dict(Rad=float(LDetsave[ii]['Rad']),O=LDetsave[ii]['BaryS'],nIn=LDetsave[ii]['nIn'])
            Sino_RefPt = None if Out['Sino_RefPt'].shape==() else Out['Sino_RefPt']
            dd = TFG.Detect(ddIdsave, Poly, Optics=Optics, Ves=Ves, VesCalc=VesCalc, Sino_RefPt=Sino_RefPt, CalcEtend=False, CalcSpanImp=False, CalcCone=False, CalcPreComp=False, Calc=True, Verb=Verb,
                            arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']))
            dd = _resetDetectAttr(dd, {'LOSprops':LOSprops, 'Sino':Sino, 'Span':Span, 'Cone':Cone, 'SAng':SAng, 'SynthDiag':SynthDiag, 'Res':Res, 'Optics':Opt})
            dd._LOS_NP = LDetsave[ii]['LOSNP']
            if dd._SynthDiag_Done and dd._SynthDiag_Points is None:
                dd.set_SigPrecomp()
            LDet.append(dd)
        obj = TFG.GDetect(Id, LDet, Type=Id.Type, Exp=Id.Exp, Diag=Id.Diag, shot=Id.shot, dtime=Id.dtime, Sino_RefPt=Out['Sino_RefPt'], LOSRef=str(Out['LOSRef']),
                          arrayorder=str(Out['arrayorder']), Clock=bool(Out['Clock']), SavePath=Id.SavePath)
        Res = Out['Res'][0] if out=='full' else Res
        for kk in Res.keys():
            setattr(obj,kk,Res[kk])

    elif Id.Cls=='Eq2D':
        Sep = [np.array(ss) for ss in Out['Sep'].tolist()]
        obj = tfEq.Eq2D(Id, Out['PtsCross'], t=Out['t'], MagAx=Out['MagAx'], Sep=Sep, rho_p=Out['rho_p'].tolist(), rho_t=Out['rho_t'].tolist(), surf=Out['surf'].tolist(), vol=Out['vol'].tolist(),
                        q=Out['q'].tolist(), jp=Out['jp'].tolist(), pf=Out['pf'].tolist(), tf=Out['tf'].tolist(), theta=Out['theta'].tolist(), thetastar=Out['thetastar'].tolist(),
                        BTX=Out['BTX'].tolist(), BRY=Out['BRY'].tolist(), BZ=Out['BZ'].tolist(), Ref=str(Out['Ref']))

    elif Id.Cls=='Mesh1D':
        obj = TFM.Mesh1D(Id, Out['Knots'])

    elif Id.Cls=='Mesh2D':
        obj = TFM.Mesh2D(Id, [Out['Knots'][0],Out['Knots'][1]])
        obj = TFM.Mesh2D(Id, Knots=obj, ind=Out['IndBg'])
        for ii in range(0,len(Out['SubMinds'])):
            obj.add_SubMesh(Name=Out['SubMinds'][ii]['Name'], ind=Out['SubMinds'][ii]['ind'])

    elif Id.Cls=='Metric1D':
        obj = TFM.Metric1D(Id)

    elif Id.Cls=='Metric2D':
        obj = TFM.Metric2D(Id)


    elif Id.Cls in 'BF2D':
        IdMesh = ID(str(Out['IdMesh'][0]), str(Out['IdMesh'][1]), SaveName=str(Out['IdMesh'][2]), SavePath=str(Out['IdMesh'][3]), dtime=Out['dtimeMesh'][0], dtFormat=str(Out['IdMesh'][4]))
        M2 = TFM.Mesh2D(IdMesh, Knots=[Out['KnotsR'],Out['KnotsZ']])
        M2bis = TFM.Mesh2D(IdMesh,Knots=M2,Ind=Out['Ind'])
        obj = TFM.BF2D(Id, M2bis, int(Out['Deg'][0]))
    elif Id.Cls=='GMat2D':
        import ToFu_MatComp as TFMC
        import scipy.sparse as scpsp
        Id.set_LObj(open_np_IdObj(['Ves','BF2D','Detect'], [Out['Ves'],Out['BF2'],Out['LDetect']], [Out['VesUSR'],Out['BF2USR'],Out['LDetectUSR']]))
        Mat = scpsp.csr_matrix((Out['Matdata'], Out['Matind'], Out['Matindpr']), shape=Out['Matshape'])
        MatLOS = scpsp.csr_matrix((Out['MatLOSdata'], Out['MatLOSind'], Out['MatLOSindpr']), shape=Out['MatLOSshape'])
        obj = TFMC.GMat2D(Id, None, None, Mat=None, indMat=None, MatLOS=None, Calcind=False, Calc=False, CalcLOS=False)
        obj._init_CompParam(Mode=str(Out['CompParamStr'][0]), epsrel=Out['CompParamVal'][0], SubP=Out['CompParamVal'][1], SubMode=str(Out['CompParamStr'][1]), SubTheta=Out['CompParamVal'][2], SubThetaMode=str(Out['CompParamStr'][2]), Fast=bool(Out['CompParamVal'][-1]), SubPind=Out['CompParamVal'][3], ModeLOS=str(Out['CompParamStr'][3]), epsrelLOS=Out['CompParamVal'][4], SubPLOS=Out['CompParamVal'][5], SubModeLOS=str(Out['CompParamStr'][4]))
        obj._BF2 = None
        obj._BF2_Deg = int(Out['BF2Par'][0])
        obj._BF2_NCents = int(Out['BF2Par'][2])
        obj._BF2_NFunc = int(Out['BF2Par'][1])
        obj._Ves = None
        obj._LD = None
        obj._LD_nDetect = int(Out['LD_nD'])
        obj._set_indMat(indMat=Out['indMat'], Verb=False)
        obj._set_MatLOS(MatLOS=MatLOS, Verb=False)
        obj._set_Mat(Mat=Mat, Verb=False)



    elif Id.Cls=='PreData':
        LIdDet = Id.get_LObjasLId('Detect') if 'Detect' in Id.LObj.keys() else None
        Init, Update = Out['Init'][0], Out['Update'][0]
        obj = tft.PreData(Init['data'], Id=Id, t=Init['t'], Chans=Init['Chans'], DtRef=Init['DtRef'], LIdDet=LIdDet)
        obj.set_Dt(Update['Dt'], Calc=False)
        obj.set_Resamp(t=Update['Resamp_t'], f=Update['Resamp_f'], Method=Update['Resamp_Method'], interpkind=Update['Resamp_interpkind'], Calc=False)
        obj.Out_add(indOut=Update['indOut'], Calc=False)
        obj.Corr_add(indCorr=Update['indCorr'], Calc=False)
        obj.interp(lt=Update['interp_lt'], lNames=Update['interp_lNames'], Calc=False)
        obj.substract_Dt(tsub=Update['Subtract_tsub'], Calc=False)
        obj.set_fft(Calc=True, **Update['FFTPar'])
        if not Update['PhysNoiseParam'] is None:
            Method = 'svd' if 'Modes' in Update['PhysNoiseParam'].keys() else 'fft'
            obj.set_PhysNoise(**Update['PhysNoiseParam'].update({'Method':Method}))


        #Id.set_LObj(open_np_IdObj(['Detect'],[Out['LDetect']], [Out['LDetectUSR']]))
        #obj = TFT.PreData(Id=Id, shot=int(Out['shot']), DLPar=Out['DLPar'].item(), Exp=str(Out['StrPar'][0]), Dt=list(Out['Dt']), DtMargin=float(Out['DtMarg']), MovMeanfreq=float(Out['MovMeanfreq']), Resamp=bool(Out['Resamp']),
        #        interpkind=str(Out['StrPar'][1]), indOut=Out['indOut'], indCorr=Out['indCorr'], lt=Out['interp_lt'], lNames=Out['interp_lN'].tolist(), Test=True)
        #if not Out['PhysNoise'].item() is None:
        #    obj.set_PhysNoise(Deg=int(Out['NoiseMod'].item()['Deg']), Nbin=int(Out['NoiseMod'].item()['Nbin']), LimRatio=float(Out['NoiseMod'].item()['LimRatio']), **Out['PhysNoise'].item()['Param'])


    elif Id.Cls=='Sol2D':
        Id.set_LObj(open_np_IdObj(['PreData','GMat2D','BF2D'],[Out['PreData'], Out['GMat2D'], Out['BF2D']], [Out['PreDataUSR'],Out['GMatUSR'],Out['BF2DUSR']]))
        GMSaveName = Id.LObj['GMat2D']['SaveName'][0]
        try:
            GMat = Open(Id.LObj['GMat2D']['SavePath'][0]+GMSaveName+'.npz')
        except Exception:
            GMSaveName = GMSaveName[:GMSaveName.index('All_')+4]+'sh'+GMSaveName[GMSaveName.index('All_')+4:]
            GMat = Open(Id.LObj['GMat2D']['SavePath'][0]+GMSaveName+'.npz')
        obj = TFI.Sol2D(Id, PreData=None, GMat=GMat, InvParam=Out['InvParam'].item(), SVesePreData=False, SVeseGMat=True, SVeseBF=True)
        obj._PreData = None
        obj._GMat = obj.GMat.get_SubGMat2D(Val=list(Out['LNames']), Crit='Name',InOut='In')
        obj._shot = int(Out['shot'])
        try:
            obj._LNames = Out['LNames'].tolist()
        except Exception:
            obj._LNames = obj.PreData.In_list()
        obj._run = bool(Out['Run'])
        if bool(Out['Run']):
            obj._LOS = bool(Out['LOS'])
            obj._t, obj._data = Out['t'], Out['data']
            obj._Coefs, obj._sigma = Out['Coefs'], Out['sigma']
            obj._Mu, obj._Chi2N, obj._R, obj._Nit = Out['Mu'], Out['Chi2N'], Out['R'], Out['Nit']
            obj._Spec = list(Out['Spec'])
            obj._timing = Out['t2']
            obj._PostTreat = list(Out['PostTreat'])