コード例 #1
0
ファイル: ModCF.py プロジェクト: lao19881213/DDFacet
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

import scipy.fftpack
from DDFacet.ToolsDir import Gaussian
import numpy as np
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import ModColor
from scipy.interpolate import interp1d as interp
from DDFacet.ToolsDir import ModToolBox
from DDFacet.Array import NpShared
from DDFacet.Other import logger
log = logger.getLogger("WTerm")  # ,disable=True)
from DDFacet.ToolsDir import ModTaper
from DDFacet.ToolsDir import ModFitPoly2D
from DDFacet.ToolsDir import ModFFTW

# np.seterr(all='raise')
# import warnings
# warnings.filterwarnings('error')


F2 = scipy.fftpack.fft2
iF2 = scipy.fftpack.ifft2
Fs = scipy.fftpack.fftshift
iFs = scipy.fftpack.ifftshift

コード例 #2
0
from DDFacet.Other import logger
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import ModColor
from DDFacet.Other.progressbar import ProgressBar
from DDFacet.Data.ClassStokes import ClassStokes
from DDFacet.Data.PointingProvider import PointingProvider
from DDFacet.Data.ClassMS import ClassMS

from astropy import wcs as pywcs
from pyrap.measures import measures
from pyrap.quanta import quantity

from functools import reduce

log=logger.getLogger("ClassMontblancMachine")

DEBUG = False

class ClassMontblancMachine(object):
    def __init__(self, GD, npix, cell_size_rad,  MS, pointing_sols):
        shndlrs = filter(lambda x: isinstance(x, logging.StreamHandler),
                         montblanc.log.handlers)
        montblanc.log.propagate = False
        log_levels = {"NOTSET": logging.NOTSET,
                      "DEBUG": logging.DEBUG,
                      "INFO": logging.INFO,
                      "WARNING": logging.WARNING,
                      "ERROR": logging.ERROR,
                      "CRITICAL": logging.CRITICAL}
        for s in shndlrs:
コード例 #3
0
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''
import numpy as np
from DDFacet.Other import logger
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import ModColor
log=logger.getLogger("ClassModelMachineSSD")
from DDFacet.Array import NpParallel
from DDFacet.Array import ModLinAlg
from DDFacet.ToolsDir import ModFFTW
from DDFacet.ToolsDir import ModToolBox
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import MyPickle
from DDFacet.Other import reformat
from DDFacet.Imager import ClassFrequencyMachine
from DDFacet.ToolsDir.GiveEdges import GiveEdges
from DDFacet.Imager import ClassModelMachine as ClassModelMachinebase
from DDFacet.ToolsDir import ModFFTW
import scipy.ndimage
from SkyModel.Sky import ModRegFile
from pyrap.images import image
from SkyModel.Sky import ClassSM
コード例 #4
0
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import os
import numpy as np
from DDFacet.Other import logger
from DDFacet.Other import ModColor
log = logger.getLogger("ClassImageDeconvMachine")
from DDFacet.Array import NpParallel
from DDFacet.Array import NpShared
from DDFacet.ToolsDir import ModFFTW
from DDFacet.ToolsDir import ModToolBox
from DDFacet.Other import ClassTimeIt
from pyrap.images import image
from DDFacet.Imager.ClassPSFServer import ClassPSFServer
from DDFacet.Other.progressbar import ProgressBar
from DDFacet.Imager import ClassGainMachine
from DDFacet.Other import MyPickle
import multiprocessing
import time
#from DDFacet.Imager.MORESANE.ClassMoresaneSingleSlice import ClassMoresaneSingleSlice
##from DDFacet.Imager.MUFFIN.easy_muffin.easy_muffin_py.deconv3d import EasyMuffin
from easy_muffin_py.deconv3d import EasyMuffin
コード例 #5
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import time as timemod
from DDFacet.Other import logger
log = logger.getLogger("ClassTimeIt")
DoLog = False


class ClassTimeIt():

    def __init__(self, name=""):
        self.t0 = timemod.time()
        self.IsEnable = True
        if name == "":
            self.name = name
        else:
            self.name = name+": "
        self.IsEnableIncr = False
        self.Counter = ""
コード例 #6
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import numpy as np
from DDFacet.Other import logger
log = logger.getLogger("ClassJones")
from DDFacet.Other import reformat
from DDFacet.Array import NpShared
import os
from DDFacet.Array import ModLinAlg
from DDFacet.Other.progressbar import ProgressBar
from DDFacet.Data import ClassLOFARBeam
from DDFacet.Data import ClassFITSBeam
# import ClassSmoothJones is not used anywhere, should be able to remove it
import tables
from scipy.interpolate import interp1d


def _parse_solsfile(SolsFile):
    """Parses the input SolsFile in order to use an input h5parm file to apply solutions on-the-fly.
        The solution directions dictate the on-the-fly facet layout.
コード例 #7
0
ファイル: Restore.py プロジェクト: dodsonicrar/DDFacet
from pyrap.images import image
import numpy as np
from DDFacet.Imager import ClassCasaImage
#from DDFacet.Imager.ModModelMachine import GiveModelMachine
from DDFacet.Imager.ModModelMachine import ClassModModelMachine
from DDFacet.Other import logger
from DDFacet.ToolsDir import ModFFTW

from DDFacet.Other import AsyncProcessPool
from DDFacet.Other.AsyncProcessPool import APP, WorkerProcessError
from DDFacet.Other import Multiprocessing

from DDFacet.Other import logger
from DDFacet.Other import MyPickle
from DDFacet.ToolsDir.rad2hmsdms import rad2hmsdms
log=logger.getLogger("ClassRestoreMachine")
import scipy.signal
import scipy.stats
import multiprocessing
NCPU_default=str(int(0.75*multiprocessing.cpu_count()))

            

def read_options():
    desc="""DDFacet """
    
    opt = optparse.OptionParser(usage='Usage: %prog <options>',version='%prog version 1.0',description=desc)
    
    group = optparse.OptionGroup(opt, "* Data selection options")
    group.add_option('--BaseImageName',help='')
    group.add_option('--ResidualImage',help='',type="str",default="")
コード例 #8
0
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import numpy as np
import warnings
warnings.simplefilter('ignore', np.RankWarning)
from scipy.optimize import curve_fit, fmin_l_bfgs_b
from DDFacet.Other import logger
from DDFacet.Imager.ClassScaleMachine import Store
log = logger.getLogger("ClassFreqMachine")


class ClassFrequencyMachine(object):
    """
    Interface to fit frequency axis in model image. All fitting is currently based on some polynomial model in normalised frequencies (v/v_0).
    For the alpha map the fit happens in log space.
        Initialisation:
                ModelCube   = A cube containing the model image with shape [NChannel,NPol,Npix,Npix]
                Freqs       = The gridding frequencies
                Freqsp      = The degridding frequencies
                ref_freq    = The reference frequency
        Methods:
                getFitMask  : Creates a mask to fit models to
                setDesMat   : Creates a design matrix in either log or normal space
                FitAlphaMap : Fits an alpha map to pixels in the model image above a user specified threshold
コード例 #9
0
    import queue
else:
    import Queue
import multiprocessing
import numpy as np
import glob
import re

from DDFacet.Other import logger
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import ModColor
from DDFacet.Other.progressbar import ProgressBar
from DDFacet.Array import NpShared
from DDFacet.Array import shared_dict

log = logger.getLogger("Multiprocessing")
#MyLogger.setSilent("Multiprocessing")

# store PID here, so that it corresponds to the PID of the parent thread (when we fork off child processes)
_pid = os.getpid()

def getShmPrefix():
    """Returns prefix used for shared memory arrays. ddf.PID is the convention"""
    return "ddf.%d" % _pid

# init SharedDict with the same base name
shared_dict.SharedDict.setBaseName(getShmPrefix())

def getShmName(name, **kw):
    """
    Forms up a name for a shm-backed shared element. This takes the form of "ddf.PID.", where PID is the
コード例 #10
0
ファイル: ClassStokes.py プロジェクト: dodsonicrar/DDFacet
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import re

import numpy as np
from DDFacet.Other import logger

log = logger.getLogger("ClassStokes")
'''
Enumeration of stokes and correlations used in MS2.0 - as per Stokes.h in casacore, the rest are left unimplemented:

These are useful when working with visibility data (https://casa.nrao.edu/Memos/229.html#SECTION000613000000000000000)
'''
StokesTypes = {
    'I': 1,
    'Q': 2,
    'U': 3,
    'V': 4,
    'RR': 5,
    'RL': 6,
    'LR': 7,
    'LL': 8,
    'XX': 9,
コード例 #11
0
from pyrap.images import image
from SkyModel.Sky import ClassSM
import optparse
import numpy as np
import glob
import os
from SkyModel.Other import reformat
SaveFile="last_MyCasapy2BBS.obj"
import pickle
import scipy.ndimage
from SkyModel.Tools import ModFFTW
from SkyModel.PSourceExtract import ClassIslands
from SkyModel.Other.ClassCasaImage import PutDataInNewImage
import scipy.special
from DDFacet.Other import logger
log=logger.getLogger("MakeMask")
from SkyModel.Other.progressbar import ProgressBar
import collections
from SkyModel.Other.MyHist import MyCumulHist
from SkyModel.PSourceExtract import Gaussian
from SkyModel.Sky import ModRegFile
from DDFacet.ToolsDir import ModFFTW
import DDFacet.Imager.SSD.ClassIslandDistanceMachine
from DDFacet.ToolsDir.rad2hmsdms import rad2hmsdms
from DDFacet.Other import MyPickle
from DDFacet.ToolsDir import ModCoord
import DDFacet.Other.MyPickle
from matplotlib.path import Path

def read_options():
    desc=""" [email protected]"""
コード例 #12
0
ファイル: ClassMS.py プロジェクト: saopicc/killMS
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from pyrap.tables import table
from killMS.Other.rad2hmsdms import rad2hmsdms
from killMS.Other import ModColor
from killMS.Other import reformat
import os
import pyrap.quanta as qa
import pyrap.measures as pm
import ephem
from DDFacet.Other import logger
log = logger.getLogger("ClassMS")
from killMS.Other import ClassTimeIt
from DDFacet.Other.progressbar import ProgressBar
import DDFacet.ToolsDir.ModRotate
#from DDFacet.Other.PrintList import ListToStr


class ClassMS():
    def __init__(self,
                 MSname,
                 Col="DATA",
                 zero_flag=True,
                 ReOrder=False,
                 EqualizeFlag=False,
                 DoPrint=True,
                 DoReadData=True,
コード例 #13
0
if six.PY3:
    import DDFacet.cbuild.Gridder._pyGridder3x as _pyGridder
else:
    import DDFacet.cbuild.Gridder._pyGridder27 as _pyGridder
##########################################################"

import numpy as np
import os
from DDFacet.Imager import ModCF
from DDFacet.ToolsDir.ModToolBox import EstimateNpix
from DDFacet.ToolsDir import ModFFTW
from DDFacet.Parset import ReadCFG
from DDFacet.Other import ClassTimeIt
from DDFacet.Data import ClassVisServer
from DDFacet.Other import logger
log = logger.getLogger("ClassDDEGridMachine")


def testGrid():
    import pylab
    # Parset=ReadCFG.Parset("%s/Parset/DefaultParset.cfg"%os.environ["DDFACET_DIR"])
    Parset = ReadCFG.Parset("%s/DDFacet/Parset/DefaultParset.cfg" %
                            os.environ["DDFACET_DIR"])
    DC = Parset.DicoPars
    # 19 (-0.01442078294460315, 0.014406238534169863) 2025 3465 -10.0

    #(array([0]), array([0]), array([1015]), array([1201]))
    #(array([0]), array([0]), array([1050]), array([1398]))
    # 17 (-0.014391694123736577, 0.01437714971330329) 2025 3465 -10.0
    #(array([0]), array([0]), array([1030]), array([1303]))
コード例 #14
0
ファイル: CleanSHM.py プロジェクト: lao19881213/DDFacet
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''
import optparse

from DDFacet.Array import NpShared
from DDFacet.Other import logger

log = logger.getLogger("ClearSHM")
from DDFacet.cbuild.Gridder import _pyGridderSmearPols as _pyGridderSmear
import glob
import os
import shutil

from DDFacet.Other import Multiprocessing


def read_options():
    desc = """CohJones Questions and suggestions: [email protected]"""

    opt = optparse.OptionParser(usage='Usage: %prog <options>',
                                version='%prog version 1.0',
                                description=desc)
コード例 #15
0
import numpy as np
import Polygon
from scipy.spatial import Voronoi
from deap import algorithms
import DeapAlgo as algorithms
from deap import base
from deap import creator
from deap import tools
#import pylab
from scipy.spatial import Voronoi
import ModVoronoi
from DDFacet.Other import logger
log = logger.getLogger("ClusterDEAP")
from DDFacet.Other import ClassTimeIt
#from scoop import futures
import multiprocessing
import scipy.stats
import Polygon

Theta = np.linspace(-np.pi, np.pi / 2, 21)


def hasStraightEdge(P):
    p = np.array(P)[0]
    dx = ((p[1:, 0] - p[:-1, 0]) == 0)
    dy = ((p[1:, 1] - p[:-1, 1]) == 0)
    if np.count_nonzero(dx) or np.count_nonzero(dy):
        return True
    return False

コード例 #16
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import collections
import random

import numpy as np
from DDFacet.Other import ClassTimeIt
from DDFacet.Other import logger
from deap import tools
from mpl_toolkits.axes_grid1 import make_axes_locatable

log = logger.getLogger("ClassArrayMethodGA")

from DDFacet.Imager.SSD.ClassParamMachine import ClassParamMachine
from DDFacet.ToolsDir.GeneDist import ClassDistMachine


class ClassArrayMethodGA():
    def __init__(self,
                 Dirty,
                 PSF,
                 ListPixParms,
                 ListPixData,
                 FreqsInfo,
                 GD=None,
                 PixVariance=1.e-2,
                 IslandBestIndiv=None,
コード例 #17
0
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import os, os.path, subprocess
import six
if six.PY3:
    import pickle as cPickle
else:
    import cPickle
import collections

from DDFacet.Other import logger, ModColor

log = logger.getLogger("CacheManager")


class CacheManager(object):
    """
    # CacheManager

    This is a simple disk-based cache management class. Usage is as follows:

        cache = CacheManager("/cache/directory")

    This creates a cache based on the specified path. Directory is created if it doesn't exist.
    If you create CacheManager with reset=True, the contents of the directory are deleted.

    Typically, you would use the cache in the following pattern:
コード例 #18
0
ファイル: DDF.py プロジェクト: dodsonicrar/DDFacet
def main(OP=None, messages=[]):
    if OP is None:
        OP = MyPickle.Load(SaveFile)
        print("Using settings from %s, then command line."%SaveFile)

    DicoConfig = OP.DicoConfig

    ImageName = DicoConfig["Output"]["Name"]
    if not ImageName:
        raise Exceptions.UserInputError("--Output-Name not specified, can't continue.")
    if not DicoConfig["Data"]["MS"]:
        raise Exceptions.UserInputError("--Data-MS not specified, can't continue.")

    # create directory if it exists
    dirname = os.path.dirname(ImageName)
    if not os.path.exists(dirname) and not dirname == "":
        os.mkdir(dirname)

    # setup logging
    logger.logToFile(ImageName + ".log", append=DicoConfig["Log"]["Append"])
    global log
    log = logger.getLogger("DDFacet")

    # disable colors and progressbars if requested
    ModColor.silent = SkyModel.Other.ModColor.silent = \
                      progressbar.ProgressBar.silent = \
                      DicoConfig["Log"]["Boring"]

    if messages:
        if not DicoConfig["Log"]["Boring"]:
            #os.system('clear')
            logo.print_logo()
        for msg in messages:
            print(msg, file=log)

    print("Checking system configuration:", file=log)
    # check for SHM size
    ram_size = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
    shm_stats = os.statvfs('/dev/shm')
    shm_size = shm_stats.f_bsize * shm_stats.f_blocks
    shm_relsize = shm_size / float(ram_size)
    shm_avail = shm_stats.f_bsize * shm_stats.f_bavail / float(ram_size)

    if shm_relsize < 0.6:
        print(ModColor.Str("""WARNING: max shared memory size is only {:.0%} of total RAM size.
            This can cause problems for large imaging jobs. A setting of 90% is recommended for 
            DDFacet and killMS. If your processes keep failing with SIGBUS or "bus error" messages,
            it is most likely for this reason. You can change the memory size by running
                $ sudo mount -o remount,size=90% /dev/shm
            To make the change permanent, edit /etc/defaults/tmps, and add a line saying "SHM_SIZE=90%".
            """.format(shm_relsize)), file=log)
    else:
        print("  Max shared memory size is {:.0%} of total RAM size; {:.0%} currently available".format(shm_relsize, shm_avail), file=log)

    try:
        output = subprocess.check_output(["/sbin/sysctl", "vm.max_map_count"],universal_newlines=True)
    except Exception:
        print(ModColor.Str("""WARNING: /sbin/sysctl vm.max_map_count failed. Unable to check this setting."""), file=log)
        max_map_count = None
    else:
        max_map_count = int(output.strip().rsplit(" ", 1)[-1])

    if max_map_count is not None:
        if max_map_count < 500000:
            print(ModColor.Str("""WARNING: sysctl vm.max_map_count = {}. 
            This may be too little for large DDFacet and killMS jobs. If you get strange "file exists" 
            errors on /dev/shm, them try to bribe, beg or threaten your friendly local sysadmin into 
            setting vm.max_map_count=1000000 in /etc/sysctl.conf.
                """.format(max_map_count)), file=log)
        else:
            print("  sysctl vm.max_map_count = {}".format(max_map_count), file=log)

    # check for memory lock limits
    import resource
    msoft, mhard = resource.getrlimit(resource.RLIMIT_MEMLOCK)
    if msoft >=0 or mhard >=0:
        print(ModColor.Str("""WARNING: your system has a limit on memory locks configured.
            This may possibly slow down DDFacet performance. You can try removing the limit by running
                $ ulimit -l unlimited
            If this gives an "operation not permitted" error, you can try to bribe, beg or threaten 
            your friendly local sysadmin into doing
                # echo "*        -   memlock     unlimited" >> /etc/security/limits.conf
        """), file=log)


    if DicoConfig["Debug"]["Pdb"] == "always":
        print("--Debug-Pdb=always: unexpected errors will be dropped into pdb", file=log)
        Exceptions.enable_pdb_on_error(ModColor.Str("DDFacet has encountered an unexpected error. Dropping you into pdb for a post-mortem.\n" +
                                           "(This is because you're running with --Debug-Pdb set to 'always'.)"))
    elif DicoConfig["Debug"]["Pdb"] == "auto" and not DicoConfig["Log"]["Boring"]:
        print("--Debug-Pdb=auto and not --Log-Boring: unexpected errors will be dropped into pdb", file=log)
        Exceptions.enable_pdb_on_error(ModColor.Str("DDFacet has encountered an unexpected error. Dropping you into pdb for a post-mortem.\n" +
            "(This is because you're running with --Debug-Pdb set to 'auto' and --Log-Boring is off.)"))

    # print current options
    OP.Print(dest=log)

    # enable memory logging
    logger.enableMemoryLogging(DicoConfig["Log"]["Memory"])

    # get rid of old shm arrays from previous runs
    Multiprocessing.cleanupStaleShm()

    # initialize random seed from config if set, or else from system time
    if DicoConfig["Misc"]["RandomSeed"] is not None:
        DicoConfig["Misc"]["RandomSeed"]=int(DicoConfig["Misc"]["RandomSeed"])
        print("random seed=%d (explicit)" % DicoConfig["Misc"]["RandomSeed"], file=log)
    else:
        DicoConfig["Misc"]["RandomSeed"] = int(time.time())
        print("random seed=%d (automatic)" % DicoConfig["Misc"]["RandomSeed"], file=log)
    np.random.seed(DicoConfig["Misc"]["RandomSeed"])

    # init NCPU for different bits of parallelism
    ncpu = int(DicoConfig["Parallel"]["NCPU"] or psutil.cpu_count())
    DicoConfig["Parallel"]["NCPU"]=ncpu
    _pyArrays.pySetOMPNumThreads(ncpu)
    NpParallel.NCPU_global = ModFFTW.NCPU_global = ncpu
    numexpr.set_num_threads(ncpu)
    print("using up to %d CPUs for parallelism" % ncpu, file=log)

    # write parset
    OP.ToParset("%s.parset"%ImageName)

    Mode = DicoConfig["Output"]["Mode"]

    # init semaphores, as they're needed for weight calculation too
    ClassFacetMachine.ClassFacetMachine.setup_semaphores(DicoConfig)

    # data machine initialized for all cases except PSF-only mode
    # psf machine initialized for all cases except Predict-only mode
    Imager = ClassDeconvMachine.ClassImagerDeconv(GD=DicoConfig,
                                                  BaseName=ImageName,
                                                  predict_only=(Mode == "Predict" or Mode == "Subtract"),
                                                  data=(Mode != "PSF"),
                                                  psf=(Mode != "Predict" and Mode != "Dirty" and Mode != "Subtract"),
                                                  readcol=(Mode != "Predict" and Mode != "PSF"),
                                                  deconvolve=("Clean" in Mode))

    Imager.Init()

    # Imager.testDegrid()
    # stop
    if "Predict" in Mode or "Subtract" in Mode:
        Imager.GivePredict()
    if "Clean" in Mode:
        Imager.main()
    elif "Dirty" in Mode:
        sparsify = DicoConfig["Comp"]["Sparsification"]
        if sparsify and isinstance(sparsify, list):
            sparsify = sparsify[0]
        Imager.GiveDirty(psf="PSF" in Mode, sparsify=sparsify)
    elif "PSF" in Mode:
        sparsify = DicoConfig["Comp"]["Sparsification"]
        if sparsify and isinstance(sparsify, list):
            sparsify = sparsify[0]
        Imager.MakePSF(sparsify=sparsify)
    elif "RestoreAndShift" == Mode:
        Imager.RestoreAndShift()
コード例 #19
0
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

from DDFacet.Imager import ClassModelMachine
from DDFacet.Imager import ClassGainMachine
from DDFacet.Other import MyPickle
from DDFacet.Other import logger
from DDFacet.Other import ModColor
log=logger.getLogger("GiveModelMachine")

class ClassModModelMachine():
    """
        This is the factory class for ModelMachine. Basically give it a dictionary containing the components of a model image
        and it instantiates and returns a copy of the correct ModelMachine. Each pickled dictionary should contain a field
        labelling which deconvolution algorithm it corresponds to.
    """
    def __init__(self,GD=None):
        """
        Input:
            GD          = Global dictionary
        """
        self.GD = GD
        self.SSDMM = None
        self.MSMFMM = None
コード例 #20
0
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""
#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import optparse
import sys
from killMS.Other import MyPickle
from killMS.Other import logo
from killMS.Other import ModColor
from DDFacet.Other import logger
import os
log = logger.getLogger("killMS")
logger.itsLog.logger.setLevel(logger.logging.CRITICAL)

sys.path = [
    name for name in sys.path
    if not (("pyrap" in name) & ("/usr/local/lib/" in name))
]

# test

#import numpy
#print numpy.__file__
#import pyrap
#print pyrap.__file__
#stop
コード例 #21
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""
import numpy as np
from killMS.Array import ModLinAlg

from DDFacet.Other import logger

log = logger.getLogger("ClassJonesDomains")


class ClassJonesDomains():
    def __init__(self):
        pass

    def GiveFreqDomains(self, ChanFreqs, ChanWidth, NChanJones=0):
        if NChanJones == 0:
            NChanJones = ChanFreqs.size
        ChanEdges = np.linspace(ChanFreqs.min() - ChanWidth / 2.,
                                ChanFreqs.max() + ChanWidth / 2.,
                                NChanJones + 1)
        FreqDomains = [[ChanEdges[iF], ChanEdges[iF + 1]]
                       for iF in range(NChanJones)]
        return np.array(FreqDomains)
コード例 #22
0
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import itertools
import numpy as np
from DDFacet.Other import logger
from DDFacet.Other import ModColor
log=logger.getLogger("ClassModelMachineHogbom")
from DDFacet.ToolsDir import ModFFTW
from DDFacet.Other import MyPickle
from DDFacet.Other import reformat
from DDFacet.Imager import ClassModelMachine as ClassModelMachinebase
from DDFacet.Imager import ClassFrequencyMachine
import scipy.ndimage
import os
from pyrap.images import image # don't remove - part of KMS requirements
from SkyModel.Sky import ClassSM # don't remove - part of KMS requirements

class ClassModelMachine(ClassModelMachinebase.ClassModelMachine):
    def __init__(self,*args,**kwargs):
        ClassModelMachinebase.ClassModelMachine.__init__(self, *args, **kwargs)
        self.DicoSMStacked={}
        self.DicoSMStacked["Type"]="Hogbom"
コード例 #23
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import os
import os.path
from pyrap.images import image

import DDFacet.Data.ClassStokes as ClassStokes
import numpy as np
from DDFacet.Other import logger

log = logger.getLogger("ClassCasaImage")
from astropy.io import fits
from astropy.wcs import WCS
from DDFacet.report_version import report_version


def FileToArray(FileName, CorrT):
    """ Read a FITS FileName file to an array """
    hdu = fits.open(FileName)
    NormImage = hdu[0].data

    if len(NormImage.shape) == 4:
        nch, npol, _, _ = NormImage.shape
    else:
        nch, nx, ny = NormImage.shape
        npol = 1
コード例 #24
0
import numpy as np
from DDFacet.Imager.MORESANE import ClassImageDeconvMachineMoresane
import copy
from DDFacet.ToolsDir.GiveEdges import GiveEdges
from DDFacet.ToolsDir.GiveEdges import GiveEdgesDissymetric
from DDFacet.Imager.ClassPSFServer import ClassPSFServer
from DDFacet.Imager.ModModelMachine import ClassModModelMachine
import multiprocessing
from DDFacet.Other import ClassTimeIt
from DDFacet.Other.progressbar import ProgressBar
import time
from DDFacet.Array import NpShared
from DDFacet.Other import logger

log = logger.getLogger("ClassInitSSDModel")
import traceback
from DDFacet.Other import ModColor
from ClassConvMachine import ClassConvMachineImages
from DDFacet.Imager import ClassMaskMachine

SilentModules = [
    "ClassPSFServer", "ClassImageDeconvMachine", "GiveModelMachine",
    "ClassModelMachineMoresane", "ClassModelMachineSSD", "pymoresane.main"
]


class ClassInitSSDModelParallel():
    def __init__(self,
                 GD,
                 NFreqBands,
                 RefFreq,
コード例 #25
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import numpy as np
import scipy.signal
from DDFacet.Imager.SSD import ClassConvMachine
from DDFacet.Other import logger
log = logger.getLogger("ClassSmearSM")
import multiprocessing
from DDFacet.Array import NpShared
from DDFacet.Array import ModLinAlg
import time
from DDFacet.Other.progressbar import ProgressBar


class ClassSmearSM():
    def __init__(self,
                 MeanResidual,
                 MeanModelImage,
                 PSFServer,
                 DeltaChi2=4.,
                 IdSharedMem="",
                 NCPU=6):
        IdSharedMem += "SmearSM."
        NpShared.DelAll(IdSharedMem)
        self.IdSharedMem = IdSharedMem
        self.NCPU = NCPU
        self.MeanModelImage = NpShared.ToShared(
コード例 #26
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import optparse
import pickle
import numpy as np
from DDFacet.Other import logger
log = logger.getLogger("DiagBL")
from DDFacet.Array import shared_dict
from DDFacet.Other.AsyncProcessPool import APP, WorkerProcessError


class ClassCovMat():
    def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)
        self.DictName = "DATA"
        log.print("I am the machine that compute the weights based")
        log.print("  on the diag(nt x nt)_iAnt:jAnt matrix")

    def giveWeigthParallel(self):
        self.DATA = shared_dict.attach(self.DictName)
        self.na = self.DATA["na"]
        for A0 in range(0, self.na):
            for A1 in range(A0 + 1, self.na):
                APP.runJob("giveWeigthChunk:%d:%d" % (A0, A1),
                           self.giveWeigthChunk,
                           args=(A0, A1,
                                 self.DATA.readwrite()))  #,serial=True)
        APP.awaitJobResults("giveWeigthChunk:*", progress="CalcWeight")
コード例 #27
0
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from builtins import str
from builtins import range
from builtins import object
from pyrap.tables import table
import sys
from DDFacet.Other import logger
log=logger.getLogger("DynSpecMS")
from DDFacet.Array import shared_dict
from DDFacet.Other.AsyncProcessPool import APP, WorkerProcessError
from DDFacet.Other import Multiprocessing
from DDFacet.Other import ModColor
from DDFacet.Other.progressbar import ProgressBar
import numpy as np
from astropy.time import Time
from astropy import constants as const
import os
from killMS.Other import reformat
from DDFacet.Other import AsyncProcessPool
import glob
from astropy.io import fits
from astropy.wcs import WCS
from DDFacet.ToolsDir.rad2hmsdms import rad2hmsdms
import scipy.stats
from killMS.Array import ModLinAlg

def AngDist(ra0,ra1,dec0,dec1):
    AC=np.arccos
    C=np.cos
コード例 #28
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import matplotlib.pyplot as pylab
from pyrap.tables import table
from killMS.Data import ClassWeighting
from DDFacet.Other import logger
log = logger.getLogger("ClassVisServer")
import numpy as np


def test():
    MSName = "BOOTES24_SB100-109.2ch8s.ms"
    BLC = ClassBLCal(MSName)
    BLC.CalcBLCal()


class ClassBLCal():
    def __init__(self, MSName):
        self.MSName = MSName
        self.Init()

    def Init(self):
コード例 #29
0
'''

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from DDFacet.compatibility import range

import numpy
import os
import os.path
import sys

from DDFacet.Other import logger

log = logger.getLogger("ClassFITSBeam")

import pyrap.tables

import numpy as np

dm = pyrap.measures.measures()
dq = pyrap.quanta

# This a list of the Stokes enums (as defined in casacore header measures/Stokes.h)
# These are referenced by the CORR_TYPE column of the MS POLARIZATION subtable.
# E.g. 5,6,7,8 corresponds to RR,RL,LR,LL
MS_STOKES_ENUMS = [
    "Undefined", "I", "Q", "U", "V", "RR", "RL", "LR", "LL", "XX", "XY", "YX",
    "YY", "RX", "RY", "LX", "LY", "XR", "XL", "YR", "YL", "PP", "PQ", "QP",
    "QQ", "RCircular", "LCircular", "Linear", "Ptotal", "Plinear", "PFtotal",
コード例 #30
0
ファイル: ModToolBox.py プロジェクト: dodsonicrar/DDFacet
import numpy as np

F = scipy.fftpack.fft
iF = scipy.fftpack.ifft
Fs = scipy.fftpack.fftshift
iFs = scipy.fftpack.ifftshift

import pyfftw
import scipy.signal
import numpy
#import pyfftw
import scipy.signal

from DDFacet.Other import logger

log = logger.getLogger("ModToolBox", disable=True)

# def EstimateNpix(Npix,Padding=1):
#     Npix=int(round(Npix))

#     NpixOrig=Npix
#     if Npix%2!=0: Npix+=1
#     Npix=ModToolBox.GiveClosestFastSize(Npix)
#     NpixOpt=Npix

#     Npix*=Padding
#     Npix=int(round(Npix))
#     if Npix%2!=0: Npix+=1
#     Npix=ModToolBox.GiveClosestFastSize(Npix)
#     print ModColor.Str("(NpixOrig, NpixOpt, NpixOptPadded): %i --> %i --> %i"%(NpixOrig,NpixOpt,Npix))
#     return NpixOpt,Npix