def _save_np(obj, pathfileext, compressed=False):

    func = np.savez_compressed if compressed else np.savez
    dId = obj.Id._todict()

    # tofu.geom
    if obj.Id.Cls=='Ves':
        func(pathfileext, Id=dId, arrayorder=obj._arrayorder, Clock=obj._Clock,
             Poly=obj.Poly, Lim=obj.Lim, Sino_RefPt=obj.sino['RefPt'],
             Sino_NP=obj.sino['NP'])

    elif obj.Id.Cls=='Struct':
        func(pathfileext, Id=dId, arrayorder=obj._arrayorder, Clock=obj._Clock,
             Poly=obj.Poly, Lim=obj.Lim, mobile=obj._mobile)

    elif obj.Id.Cls in ['Rays','LOS','LOSCam1D','LOSCam2D']:
        func(pathfileext, Id=dId, extra=obj._extra,
             geom=obj.geom, sino=obj.sino, dchans=obj.dchans)

    elif obj.Id.Cls in ['Data','Data1D','Data2D']:
        dsave = obj._todict()
        if dsave['geom'] is not None and dsave['geom']['LCam'] is not None:
            LCam = []
            for cc in dsave['geom']['LCam']:
                pathS = cc['Id']['SavePath']
                pathN = cc['Id']['SaveName']
                LCam.append(os.path.join(pathS,pathN+'.npz'))
            dsave['geom'] = LCam
        elif dsave['geom'] is not None:
            geom = []
            if dsave['geom']['Ves'] is not None:
                pathS = dsave['geom']['Ves']['Id']['SavePath']
                pathN = dsave['geom']['Ves']['Id']['SaveName']
                Ves = os.path.join(pathS,pathN+'.npz')
                geom += [Ves]
            if dsave['geom']['LStruct'] is not None:
                for ss in dsave['geom']['LStruct']:
                    sf = os.path.join(ss['Id']['SavePath'],
                                      ss['Id']['SaveName']+'.npz')
                    geom += [sf]
            dsave['geom'] = geom
        func(pathfileext, **dsave)

    """
    elif obj.Id.Cls=='GLOS':
        LIdLOS = [ll.Id.todict() for ll in obj.LLOS]
        LDs, Lus = np.array([ll.D for ll in obj.LLOS]).T, np.array([ll.u for ll in obj.LLOS]).T
        func(pathfileext, Idsave=Idsave, LIdLOS=LIdLOS, LDs=LDs, Lus=Lus, Sino_RefPt=obj.Sino_RefPt, arrayorder=obj._arrayorder, Clock=obj._Clock)

    elif obj.Id.Cls=='Lens':
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, O=obj.O, nIn=obj.nIn, Rad=[obj.Rad], F1=[obj.F1], F2=[obj.F2], R1=[obj.R1], R2=[obj.R2], dd=[obj.dd])

    elif obj.Id.Cls=='Apert':
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, Poly=obj.Poly)

    elif obj.Id.Cls=='Detect':
        LOSprops, Sino, Span, Cone, SAng, SynthDiag, Res, Optics = _convert_Detect2Ldict(obj)
        VesCalc = {'SavePath':None} if (not hasattr(obj,'_VesCalc') or obj._VesCalc is None) else {'SavePath':obj._VesCalc.Id.SavePath, 'SaveName':obj._VesCalc.Id.SaveName}
        func(pathfileext, Idsave=Idsave, Poly=obj.Poly, Rad=obj.Rad, BaryS=obj.BaryS, nIn=obj.nIn, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt, LOSNP=[obj._LOS_NP],
                LOSprops=[LOSprops], Sino=[Sino], Span=[Span], Cone=[Cone], SAng=[SAng], SynthDiag=[SynthDiag], Res=[Res], Optics=[Optics], VesCalc=[VesCalc])

    elif obj.Id.Cls=='GDetect':
        LDetsave, LDetSynthRes = [], []
        for ii in range(0,obj.nDetect):
            ddIdsave = obj.LDetect[ii].Id.todict()
            LOSprops, Sino, Span, Cone, SAng, SynthDiag, Res, Optics = _convert_Detect2Ldict(obj.LDetect[ii])
            VesCalc = {'SavePath':None} if (not hasattr(obj.LDetect[ii],'_VesCalc') or obj.LDetect[ii]._VesCalc is None) else {'SavePath':obj.LDetect[ii]._VesCalc.Id.SavePath, 'SaveName':obj.LDetect[ii]._VesCalc.Id.SaveName}
            dd = dict(Idsave=ddIdsave, Poly=obj.LDetect[ii].Poly, Rad=obj.LDetect[ii].Rad, BaryS=obj.LDetect[ii].BaryS, nIn=obj.LDetect[ii].nIn, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt,
                      LOSNP=[obj.LDetect[ii]._LOS_NP], LOSprops=[LOSprops], Sino=[Sino], Span=[Span], Cone=[Cone], SAng=[SAng], Optics=[Optics], VesCalc=[VesCalc])
            LDetsave.append(dd)
            LDetSynthRes.append({'SynthDiag':[SynthDiag],'Res':[Res]})
        Res, lAttr = {}, dir(obj)
        for pp in lAttr:
            if not inspect.ismethod(getattr(obj,pp)) and '_Res' in pp:
                Res[pp] = getattr(obj,pp)
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt, LOSRef=obj._LOSRef, Res=[Res], LDetsave=LDetsave, LDetSynthRes=LDetSynthRes)

    # tofu.Eq
    elif obj.Id.Cls=='Eq2D':
        np.savez(pathfileext, Idsave=Idsave, **obj._Tab)

    # tofu.mesh
    elif obj.Id.Cls=='Mesh1D':
        func(pathfileext, Idsave=Idsave, Knots=obj.Knots)

    elif obj.Id.Cls=='Mesh2D':
        SubMinds = [{'Name':kk, 'ind':obj._SubMesh[kk]['ind']} for kk in obj._SubMesh.keys()]
        func(pathfileext, Idsave=Idsave, Knots=[obj.MeshX1.Knots,obj.MeshX2.Knots], SubMinds=SubMinds, IndBg=obj._get_CentBckg()[1])

    elif obj.Id.Cls=='BF2D':
        Id = np.array(['BF2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        IdMesh = np.array(['Mesh2D',obj.Mesh.Id.Name,obj.Mesh.Id.SaveName,obj.Mesh.Id.SavePath,obj.Mesh.Id._dtFormat],dtype=str)
        dtime, dtimeMesh = np.array([obj.Id._dtime],dtype=object), np.array([obj.Mesh.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        func(pathfileext, Id=Id, IdMesh=IdMesh, dtime=dtime, IdUSR=USR, dtimeMesh=dtimeMesh, KnotsR=obj.Mesh.MeshR.Knots, KnotsZ=obj.Mesh.MeshZ.Knots, Deg=np.array([obj.Deg],dtype=int), Ind=obj.Mesh._get_CentBckg()[1])

    # tofu.matcomp
    elif obj.Id.Cls=='GMat2D':
        Id = np.array(['GMat2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        dtime = np.array([obj.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        CompParamVal = np.array([obj._Mat_epsrel, obj._Mat_SubP, obj._Mat_SubTheta, obj._indMat_SubP, obj._MatLOS_epsrel, obj._MatLOS_SubP, int(obj._Mat_Fast)])
        CompParamStr = np.array([obj._Mat_Mode, obj._Mat_SubMode, obj._Mat_SubThetaMode, obj._MatLOS_Mode, obj._MatLOS_SubMode])
        func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, Ves=IdObj[2], VesUSR=IdObjUSR[2], LDetect=IdObj[1], BF2=IdObj[0], BF2USR=IdObjUSR[0], LDetectUSR=IdObjUSR[1], CompParamVal=CompParamVal,
                CompParamStr=CompParamStr, indMat=obj._indMat, Matdata=obj._Mat_csr.data, Matind=obj._Mat_csr.indices, Matindpr=obj._Mat_csr.indptr, Matshape=obj._Mat_csr.shape,
                MatLOSdata=obj._MatLOS_csr.data, MatLOSind=obj._MatLOS_csr.indices, MatLOSindpr=obj._MatLOS_csr.indptr, MatLOSshape=obj._MatLOS_csr.shape,
                BF2Par=np.array([obj._BF2_Deg,obj._BF2_NFunc,obj._BF2_NCents]), LD_nD=obj._LD_nDetect)

    # tofu.treat
    elif obj.Id.Cls=='PreData':
        Init, Update = _convert_PreData2Ldict(obj)
        func(pathfileext, Idsave=Idsave, Init=[Init], Update=[Update])

        #Id = np.array(['PreData',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        #dtime = np.array([obj.Id._dtime],dtype=object)
        #USR = np.asarray(obj.Id.USRdict)
        #IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        #StrPar = np.asarray([obj._Exp, obj._interpkind])
        #func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, LDetect=IdObj[0], LDetectUSR=IdObjUSR[0],
        #        DLPar=obj._DLPar, shot=obj._shot, StrPar=StrPar, Dt=obj._Dt, DtMarg=obj._DtMargin, MovMeanfreq=obj._MovMeanfreq, Resamp=obj._Resamp,
        #        indOut=obj._indOut, indCorr=obj._indCorr, PhysNoise=obj._PhysNoise, NoiseMod=obj._NoiseModel, interp_lt=obj._interp_lt, interp_lN=obj._interp_lNames)

    # tofu.inv
    elif obj.Id.Cls=='Sol2D':
        Id = np.array(['Sol2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        dtime = np.array([obj.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        try:
            timing = obj._timing
        except Exception:
            timing = obj._t2
        func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, PreData=IdObj[2], PreDataUSR=IdObjUSR[2], GMat2D=IdObj[1], GMatUSR=IdObjUSR[1], BF2D=IdObj[0], BF2DUSR=IdObjUSR[0],
                InvParam=obj.InvParam, shot=obj.shot, LNames=obj._LNames, Run=obj._run,
                LOS=obj._LOS, data=obj._data, t=obj._t, Coefs=obj._Coefs, sigma=obj._sigma, Mu=obj._Mu, Chi2N=obj._Chi2N, R = obj._R, Nit=obj._Nit, Spec=obj._Spec, t2=timing, PostTreat=obj._PostTreat)
    """
elif obj.Id.Cls=='GLOS':
        LIdLOS = [ll.Id.todict() for ll in obj.LLOS]
        LDs, Lus = np.array([ll.D for ll in obj.LLOS]).T, np.array([ll.u for ll in obj.LLOS]).T
        func(pathfileext, Idsave=Idsave, LIdLOS=LIdLOS, LDs=LDs, Lus=Lus, Sino_RefPt=obj.Sino_RefPt, arrayorder=obj._arrayorder, Clock=obj._Clock)

    elif obj.Id.Cls=='Lens':
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, O=obj.O, nIn=obj.nIn, Rad=[obj.Rad], F1=[obj.F1], F2=[obj.F2], R1=[obj.R1], R2=[obj.R2], dd=[obj.dd])

    elif obj.Id.Cls=='Apert':
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, Poly=obj.Poly)

    elif obj.Id.Cls=='Detect':
        LOSprops, Sino, Span, Cone, SAng, SynthDiag, Res, Optics = _convert_Detect2Ldict(obj)
        VesCalc = {'SavePath':None} if (not hasattr(obj,'_VesCalc') or obj._VesCalc is None) else {'SavePath':obj._VesCalc.Id.SavePath, 'SaveName':obj._VesCalc.Id.SaveName}
        func(pathfileext, Idsave=Idsave, Poly=obj.Poly, Rad=obj.Rad, BaryS=obj.BaryS, nIn=obj.nIn, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt, LOSNP=[obj._LOS_NP],
                LOSprops=[LOSprops], Sino=[Sino], Span=[Span], Cone=[Cone], SAng=[SAng], SynthDiag=[SynthDiag], Res=[Res], Optics=[Optics], VesCalc=[VesCalc])

    elif obj.Id.Cls=='GDetect':
        LDetsave, LDetSynthRes = [], []
        for ii in range(0,obj.nDetect):
            ddIdsave = obj.LDetect[ii].Id.todict()
            LOSprops, Sino, Span, Cone, SAng, SynthDiag, Res, Optics = _convert_Detect2Ldict(obj.LDetect[ii])
            VesCalc = {'SavePath':None} if (not hasattr(obj.LDetect[ii],'_VesCalc') or obj.LDetect[ii]._VesCalc is None) else {'SavePath':obj.LDetect[ii]._VesCalc.Id.SavePath, 'SaveName':obj.LDetect[ii]._VesCalc.Id.SaveName}
            dd = dict(Idsave=ddIdsave, Poly=obj.LDetect[ii].Poly, Rad=obj.LDetect[ii].Rad, BaryS=obj.LDetect[ii].BaryS, nIn=obj.LDetect[ii].nIn, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt,
                      LOSNP=[obj.LDetect[ii]._LOS_NP], LOSprops=[LOSprops], Sino=[Sino], Span=[Span], Cone=[Cone], SAng=[SAng], Optics=[Optics], VesCalc=[VesCalc])
            LDetsave.append(dd)
            LDetSynthRes.append({'SynthDiag':[SynthDiag],'Res':[Res]})
        Res, lAttr = {}, dir(obj)
        for pp in lAttr:
            if not inspect.ismethod(getattr(obj,pp)) and '_Res' in pp:
                Res[pp] = getattr(obj,pp)
        func(pathfileext, Idsave=Idsave, arrayorder=obj._arrayorder, Clock=obj._Clock, Sino_RefPt=obj.Sino_RefPt, LOSRef=obj._LOSRef, Res=[Res], LDetsave=LDetsave, LDetSynthRes=LDetSynthRes)

    # tofu.Eq
    elif obj.Id.Cls=='Eq2D':
        np.savez(pathfileext, Idsave=Idsave, **obj._Tab)

    # tofu.mesh
    elif obj.Id.Cls=='Mesh1D':
        func(pathfileext, Idsave=Idsave, Knots=obj.Knots)

    elif obj.Id.Cls=='Mesh2D':
        SubMinds = [{'Name':kk, 'ind':obj._SubMesh[kk]['ind']} for kk in obj._SubMesh.keys()]
        func(pathfileext, Idsave=Idsave, Knots=[obj.MeshX1.Knots,obj.MeshX2.Knots], SubMinds=SubMinds, IndBg=obj._get_CentBckg()[1])

    elif obj.Id.Cls=='BF2D':
        Id = np.array(['BF2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        IdMesh = np.array(['Mesh2D',obj.Mesh.Id.Name,obj.Mesh.Id.SaveName,obj.Mesh.Id.SavePath,obj.Mesh.Id._dtFormat],dtype=str)
        dtime, dtimeMesh = np.array([obj.Id._dtime],dtype=object), np.array([obj.Mesh.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        func(pathfileext, Id=Id, IdMesh=IdMesh, dtime=dtime, IdUSR=USR, dtimeMesh=dtimeMesh, KnotsR=obj.Mesh.MeshR.Knots, KnotsZ=obj.Mesh.MeshZ.Knots, Deg=np.array([obj.Deg],dtype=int), Ind=obj.Mesh._get_CentBckg()[1])

    # tofu.matcomp
    elif obj.Id.Cls=='GMat2D':
        Id = np.array(['GMat2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        dtime = np.array([obj.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        CompParamVal = np.array([obj._Mat_epsrel, obj._Mat_SubP, obj._Mat_SubTheta, obj._indMat_SubP, obj._MatLOS_epsrel, obj._MatLOS_SubP, int(obj._Mat_Fast)])
        CompParamStr = np.array([obj._Mat_Mode, obj._Mat_SubMode, obj._Mat_SubThetaMode, obj._MatLOS_Mode, obj._MatLOS_SubMode])
        func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, Ves=IdObj[2], VesUSR=IdObjUSR[2], LDetect=IdObj[1], BF2=IdObj[0], BF2USR=IdObjUSR[0], LDetectUSR=IdObjUSR[1], CompParamVal=CompParamVal,
                CompParamStr=CompParamStr, indMat=obj._indMat, Matdata=obj._Mat_csr.data, Matind=obj._Mat_csr.indices, Matindpr=obj._Mat_csr.indptr, Matshape=obj._Mat_csr.shape,
                MatLOSdata=obj._MatLOS_csr.data, MatLOSind=obj._MatLOS_csr.indices, MatLOSindpr=obj._MatLOS_csr.indptr, MatLOSshape=obj._MatLOS_csr.shape,
                BF2Par=np.array([obj._BF2_Deg,obj._BF2_NFunc,obj._BF2_NCents]), LD_nD=obj._LD_nDetect)

    # tofu.treat
    elif obj.Id.Cls=='PreData':
        Init, Update = _convert_PreData2Ldict(obj)
        func(pathfileext, Idsave=Idsave, Init=[Init], Update=[Update])

        #Id = np.array(['PreData',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        #dtime = np.array([obj.Id._dtime],dtype=object)
        #USR = np.asarray(obj.Id.USRdict)
        #IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        #StrPar = np.asarray([obj._Exp, obj._interpkind])
        #func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, LDetect=IdObj[0], LDetectUSR=IdObjUSR[0],
        #        DLPar=obj._DLPar, shot=obj._shot, StrPar=StrPar, Dt=obj._Dt, DtMarg=obj._DtMargin, MovMeanfreq=obj._MovMeanfreq, Resamp=obj._Resamp,
        #        indOut=obj._indOut, indCorr=obj._indCorr, PhysNoise=obj._PhysNoise, NoiseMod=obj._NoiseModel, interp_lt=obj._interp_lt, interp_lN=obj._interp_lNames)

    # tofu.inv
    elif obj.Id.Cls=='Sol2D':
        Id = np.array(['Sol2D',obj.Id.Name,obj.Id.SaveName,obj.Id.SavePath,obj.Id._dtFormat,obj.Id._Diag,str(obj.Id._shot), [obj.Id.Type], obj.Id.Exp],dtype=str)
        dtime = np.array([obj.Id._dtime],dtype=object)
        USR = np.asarray(obj.Id.USRdict)
        IdObj, IdObjUSR = save_np_IdObj(obj.Id)
        try:
            timing = obj._timing
        except Exception:
            timing = obj._t2
        func(pathfileext, Id=Id, dtime=dtime, IdUSR=USR, PreData=IdObj[2], PreDataUSR=IdObjUSR[2], GMat2D=IdObj[1], GMatUSR=IdObjUSR[1], BF2D=IdObj[0], BF2DUSR=IdObjUSR[0],
                InvParam=obj.InvParam, shot=obj.shot, LNames=obj._LNames, Run=obj._run,
                LOS=obj._LOS, data=obj._data, t=obj._t, Coefs=obj._Coefs, sigma=obj._sigma, Mu=obj._Mu, Chi2N=obj._Chi2N, R = obj._R, Nit=obj._Nit, Spec=obj._Spec, t2=timing, PostTreat=obj._PostTreat)