Ejemplo n.º 1
0
def im_params(vis,pblevel=0.1):
    # return a good cell size and imsize (in pixels) for the ms
    import analysisUtils as au
    cell,imsize,fieldID=au.pickCellSize(vis,imsize=True,pblevel=pblevel,npix=3)
    if imsize[0]<5000:
        cell,imsize,fieldID=au.pickCellSize(vis,imsize=True,pblevel=pblevel,npix=5)
    pixelsize = str(cell) + 'arcsec'
    npixels = imsize[0]
    print 'Pixel size:', pixelsize, '/ Image size:', npixels, 'pixels'
    return pixelsize,npixels
Ejemplo n.º 2
0
def im_params(vis, pblevel=0.1):
    # return a good cell size and imsize (in pixels) for the ms
    import analysisUtils as au
    cell, imsize, fieldID = au.pickCellSize(vis,
                                            imsize=True,
                                            pblevel=pblevel,
                                            npix=3)
    if imsize[0] < 5000:
        cell, imsize, fieldID = au.pickCellSize(vis,
                                                imsize=True,
                                                pblevel=pblevel,
                                                npix=5)
    pixelsize = str(cell) + 'arcsec'
    npixels = imsize[0]
    print 'Pixel size:', pixelsize, '/ Image size:', npixels, 'pixels'
    return pixelsize, npixels
Ejemplo n.º 3
0
def image_dimensions(vis, oversamplerate=5, magnify_ratio=1.2):
    # Dimensions from analysisUtils
    au_cellsize, au_imsize, au_oversample = \
        au.pickCellSize(vis=vis, imsize=True, npix=oversamplerate)
    # Determine cellsize
    if au_cellsize < 1.0:
        cellsize_arcsec = 1.0
    else:
        cellsize_arcsec = int(au_cellsize * 2) / 2.0
    cellsize_str = str(cellsize_arcsec) + 'arcsec'
    # Determin image size
    valid_sizes = []
    for ii in range(10):
        for kk in range(3):
            for jj in range(3):
                valid_sizes.append(2**(ii+1)*5**(jj)*3**(kk))
    valid_sizes.sort()
    valid_sizes = np.array(valid_sizes)
    need_cells_x = au_imsize[0] * magnify_ratio * au_cellsize / cellsize_arcsec
    need_cells_y = au_imsize[1] * magnify_ratio * au_cellsize / cellsize_arcsec
    cells_x = np.min(valid_sizes[valid_sizes > need_cells_x])
    cells_y = np.min(valid_sizes[valid_sizes > need_cells_y])
    imsize = [cells_x, cells_y]
    return cellsize_str, cellsize_arcsec, imsize
def checksource(overwrite=True, verbose=False, subdir='', splitcal_vis=''):
    """
    Images the phasecal and check source in a manually-calibrated dataset and 
    reports statistics.  Expects to find the *.split.cal measurement set and 
    the corresponding .fluxscale file for it.
    Inputs:
    overwrite: if True, overwrite any existing image from a previous execution
    splitcal_vis: defaults to *.cal, but can be specified as list of strings, 
                  or a comma-delimited string
    Outputs:
    png image plots of each calibrator, and an ASCII file for each dataset
    The name of the ASCII file, and a list of pngs are returned.
    """
    # Read the dataset(s) and get properties
    if (splitcal_vis == ''):
        vislist = glob.glob('*.cal')
    else:
        if (type(splitcal_vis) == str):
            vislist = splitcal_vis.split(',')
        else:
            vislist = splitcal_vis
    print("Checking datasets: ", vislist)
    mymsmd = au.createCasaTool(msmdtool)
    if (len(subdir) > 0):
        if (os.path.exists(subdir)):
            if (subdir[-1] != '/'):
                subdir += '/'
        else:
            os.mkdir(subdir)
            if (subdir[-1] != '/'):
                subdir += '/'
    pnglist = []
    textfiles = []
    for vis in vislist:
        mymsmd.open(vis)
        freq = mymsmd.meanfreq(0, unit='GHz')
        # Check Source
        check = mymsmd.fieldsforintent('OBSERVE_CHECK_SOURCE*', True)[0]
        checkid = mymsmd.fieldsforintent('OBSERVE_CHECK_SOURCE*', False)[0]
        checkpos = mymsmd.phasecenter(checkid)
        # Phase calibrator
        phase = mymsmd.fieldsforintent('CALIBRATE_PHASE*', True)[0]
        phaseid = mymsmd.fieldsforintent('CALIBRATE_PHASE*', False)[0]
        phasepos = mymsmd.phasecenter(phaseid)
        if ('OBSERVE_TARGET#ON_SOURCE' in mymsmd.intents()):
            nScienceFields = len(
                mymsmd.fieldsforintent('OBSERVE_TARGET*', False))
            science = mymsmd.fieldsforintent('OBSERVE_TARGET*', True)[0]
            scienceid = mymsmd.fieldsforintent('OBSERVE_TARGET*', False)[0]
        else:
            nScienceFields = 0
        mymsmd.done()

        floatcell = au.pickCellSize(vis,
                                    maxBaselinePercentile=99,
                                    verbose=verbose)
        cell = au.pickCellSize(vis,
                               maxBaselinePercentile=99,
                               cellstring=True,
                               verbose=verbose)
        #        imsize = int(au.nextValidImsize(int(5.0/floatcell))) # valid when we only had checksources for synthBeam < 0.25
        imsize = int(
            au.nextValidImsize(
                int(
                    np.max([5.0, 5.0 * au.estimateSynthesizedBeam(vis)]) /
                    floatcell)))
        print("imsize = ", imsize)
        region = 'circle[[%dpix , %dpix], 15pix ]' % (int(
            imsize / 2), int(imsize / 2))

        if False:
            # original method (for bands 3-6 only)
            cell = str(np.round(0.015 * (100 / freq), 3)) + 'arcsec'
            if freq < 116.0:
                imsize = [320, 320]
                region = 'circle[[160pix , 160pix] ,15pix ]'
            else:
                imsize = [680, 680]
                region = 'circle[[340pix , 340pix] ,15pix ]'

        ###################################
        # IMAGE
        ###################################
        weighting = 'briggs'
        robust = 0.5
        niter = 50
        threshold = '0.0mJy'
        spw = ''
        separation = au.angularSeparationOfTwoFields(vis, checkid, phaseid)
        if (nScienceFields > 0):
            separation_pcal_science = au.angularSeparationOfTwoFields(
                vis, scienceid, phaseid)
            separation_check_science = au.angularSeparationOfTwoFields(
                vis, scienceid, checkid)

        fieldtype = ['checksource', 'phasecal']
        field = [check, phase]
        for i, cal in enumerate(field):
            if (not os.path.exists(cal + '_' + vis + '.image') or overwrite):
                os.system('rm -rf ' + cal + '_' + vis + '.*')
                if verbose:
                    print(
                        "Running tclean('%s', field='%s', cell=%s, imsize=%s, ...)"
                        % (vis, cal, str(cell), str(imsize)))
                tclean(vis=vis,
                       imagename=cal + '_' + vis,
                       field=cal,
                       spw=spw,
                       specmode='mfs',
                       deconvolver='hogbom',
                       imsize=imsize,
                       cell=cell,
                       weighting=weighting,
                       robust=robust,
                       niter=niter,
                       threshold=threshold,
                       interactive=False,
                       mask=region,
                       gridder='standard')
            png = subdir + fieldtype[i] + '_' + cal + '_' + vis + '.image.png'
            pnglist.append(png)
            au.imviewField(cal + '_' + vis + '.image',
                           radius=30 * floatcell,
                           contourImage=cal + '_' + vis + '.mask',
                           levels=[1],
                           plotfile=png)

        ###################################
        # ANALYZE
        ###################################
        ###########
        # PHASE
        ###########
        imagename = phase + '_' + vis
        if verbose:
            print("Running imfit('%s', region='%s')" %
                  (imagename + '.image', region))
        # Fit the phase source to get position and flux
        imagefit = imfit(imagename=imagename + '.image', region=region)
        fitresults = au.imfitparse(imagefit)

        # Compare the Positions
        phasepos_obs = au.direction2radec(phasepos)
        if fitresults is not None:
            phasepos_fit = ','.join(fitresults.split()[:2])
            phasepos_diff = au.angularSeparationOfStrings(
                phasepos_obs, phasepos_fit, verbose=False) * 3600.

        # Compare the Flux densities
        peakIntensity = au.imagePeak(imagename + '.image')
        selffluxfile = glob.glob('*.fluxscale')[0]
        fluxscaleResult = au.fluxscaleParseLog(selffluxfile, field=phase)
        if fluxscaleResult is not None:
            selfflux = fluxscaleResult[0][0]
            phaseflux_fit = float(fitresults.split()[2])
            phaseCoherence = 100 * peakIntensity / phaseflux_fit
            phaseflux_diff = 100 * (selfflux - phaseflux_fit) / selfflux

        # Print the final results and save to file
        textfile = subdir + 'calimage_results_' + vis + '.txt'
        textfiles.append(textfile)
        f = open(textfile, 'w')
        f.write(
            '\n*************************************************************\n\n'
        )
        line = 'CHECK_SOURCE IMAGE ANALYSIS REPORT (version %s)\n' % version(
            short=True)
        writeOut(f, line)
        info = au.getFitsBeam(imagename + '.image')
        synthBeam = (info[0] * info[1])**0.5
        if fitresults is None:
            line = "Phasecal %s: imfit failed" % (phase)
        elif fluxscaleResult is not None:
            line = "Phasecal %s: Position difference = %s arcsec = %s synth.beam, Flux %% difference = %s" % (
                phase, au.roundFiguresToString(phasepos_diff, 3),
                au.roundFiguresToString(phasepos_diff / synthBeam, 3),
                au.roundFiguresToString(phaseflux_diff, 3))
            writeOut(f, line)
            line = "    coherence = peakIntensity/fittedFluxDensity = %s%%" % (
                au.roundFiguresToString(phaseCoherence, 3))
        else:
            line = "Phasecal %s: Position difference = %s arcsec = %s synth.beam" % (
                phase, au.roundFiguresToString(phasepos_diff, 3),
                au.roundFiguresToString(phasepos_diff / synthBeam, 3))
        writeOut(f, line)
        f.close()
        if fluxscaleResult is None:
            print(
                "Full checksource analysis is not supported if there is no flux calibrator"
            )
            return textfiles, pnglist

        ###########
        # CHECK
        ###########
        imagename = check + '_' + vis
        # Fit the check source to get position and flux
        if verbose:
            print("Running imfit('%s', region='%s')" %
                  (imagename + '.image', region))
        imagefit = imfit(imagename=imagename + '.image', region=region)
        fitresults = au.imfitparse(imagefit, deconvolved=True)
        info = au.getFitsBeam(imagename + '.image')
        synthMajor, synthMinor = info[0:2]
        synthBeam = (info[0] * info[1])**0.5

        # Compare the Positions
        checkpos_obs = au.direction2radec(checkpos)
        if fitresults is not None:
            checkpos_fit = ','.join(fitresults.split()[:2])
            checkpos_diff = au.angularSeparationOfStrings(
                checkpos_obs, checkpos_fit, verbose=False) * 3600.

        # Compare the Flux densities
        selffluxfile = glob.glob('*.fluxscale')[0]
        results = au.fluxscaleParseLog(selffluxfile, field=check)
        peakIntensity = au.imagePeak(imagename + '.image')
        if (results is not None and fitresults is not None):
            selfflux = results[0][0]
            checkflux_fit = float(fitresults.split()[2])

            checkflux_diff = 100 * (selfflux - checkflux_fit) / selfflux
            checkCoherence = 100 * peakIntensity / checkflux_fit
        if fitresults is not None:
            if verbose:
                print("Checksource fitresults: ", fitresults)
            deconvolvedMajor = float(fitresults.split()[5])
            deconvolvedMinor = float(fitresults.split()[7])

        # Print the final results and save to file
        f = open(textfile, 'a')
        if fitresults is None:
            line = "Checksource %s: imfit failed" % (phase)
        else:
            if (results is not None):
                line = "\nChecksource %s: Position difference = %s arcsec = %s synth.beam, Flux %% difference = %s" % (
                    check, au.roundFiguresToString(checkpos_diff, 3),
                    au.roundFiguresToString(checkpos_diff / synthBeam, 3),
                    au.roundFiguresToString(checkflux_diff, 3))
                writeOut(f, line)
                line = "    coherence = peakIntensity/fittedFluxDensity = %s%%" % (
                    au.roundFiguresToString(checkCoherence, 3))
            else:
                line = "\nChecksource %s: Position difference = %s arcsec = %s synth.beam" % (
                    check, au.roundFiguresToString(checkpos_diff, 3),
                    au.roundFiguresToString(checkpos_diff / synthBeam, 3))
            writeOut(f, line)
            line = "    beam size = %s x %s arcsec" % (au.roundFiguresToString(
                synthMajor, 3), au.roundFiguresToString(synthMinor, 3))
            writeOut(f, line)
            line = "    apparent deconvolved size = %s x %s arcsec = %s synth.beam area" % (
                au.roundFiguresToString(deconvolvedMajor, 2),
                au.roundFiguresToString(deconvolvedMinor, 2),
                au.roundFiguresToString(
                    deconvolvedMajor * deconvolvedMinor / (synthBeam**2), 2))
        writeOut(f, line)
        line = "    angular separation of phasecal to checksource = %s degree" % (
            au.roundFiguresToString(separation, 3))
        writeOut(f, line)
        if (nScienceFields > 0):
            if (nScienceFields > 1):
                modifier = 'first'
            else:
                modifier = 'only'
            line = "    angular separation of phasecal to %s science field (%d) = %s degree" % (
                modifier, scienceid,
                au.roundFiguresToString(separation_pcal_science, 3))
            writeOut(f, line)
            line = "    angular separation of checksource to %s science field (%d) = %s degree" % (
                modifier, scienceid,
                au.roundFiguresToString(separation_check_science, 3))
            writeOut(f, line)
        f.close()
    # end 'for' loop over vislist
    return textfiles, pnglist
def estimate_cell_and_imsize(
    infile=None,
    clean_call=None,
    oversamp=5,
    force_square=False,
):
    """
    Pick a cell and image size for a measurement set. Requests an
    oversampling factor, which is by default 5. Will pick a good size
    for the FFT and will try to pick a round number for the cell
    size. Returns variables appropriate for cell= and imsize= in
    tclean.
    """

    if not os.path.isdir(infile):
        logger.error('Error! The input file "' + infile + '" was not found!')
        return

    # If supplied, use the clean call to determine pblevel

    if not isinstance(clean_call, CleanCall):
        pblevel = 0.2
    else:
        pblevel = clean_call.get_param('pblimit')

    # These are the CASA-preferred sizes for fast FFTs

    valid_sizes = []
    for ii in range(10):
        for kk in range(3):
            for jj in range(3):
                valid_sizes.append(2**(ii + 1) * 5**jj * 3**kk)
    valid_sizes.sort()
    valid_sizes = np.array(valid_sizes)

    # Cell size implied by baseline distribution from analysis
    # utilities.

    au_cellsize, au_imsize, _ = au.pickCellSize(
        infile,
        imsize=True,
        npix=oversamp,
        intent='',
        pblevel=pblevel,
    )
    xextent = au_cellsize * au_imsize[0] * 1.2
    yextent = au_cellsize * au_imsize[1] * 1.2

    # Make the cell size a nice round number

    if au_cellsize < 0.1:
        cell_size = au_cellsize
    elif 0.1 <= au_cellsize < 0.5:
        cell_size = np.floor(au_cellsize / 0.05) * 0.05
    elif 0.5 <= au_cellsize < 1.0:
        cell_size = np.floor(au_cellsize / 0.1) * 0.1
    elif 1.0 <= au_cellsize < 2.0:
        cell_size = np.floor(au_cellsize / 0.25) * 0.25
    elif 2.0 <= au_cellsize < 5.0:
        cell_size = np.floor(au_cellsize / 0.5) * 0.5
    else:
        cell_size = np.floor(au_cellsize / 1.0) * 0.5

    # Now make the image size a good number for the FFT

    need_cells_x = xextent / cell_size
    need_cells_y = yextent / cell_size

    cells_x = np.min(valid_sizes[valid_sizes > need_cells_x])
    cells_y = np.min(valid_sizes[valid_sizes > need_cells_y])

    # If requested, force the mosaic to be square. This avoids
    # pathologies in CASA versions 5.1 and 5.3.

    if force_square:
        if cells_y < cells_x:
            cells_y = cells_x
        if cells_x < cells_y:
            cells_x = cells_y

    image_size = [int(cells_x), int(cells_y)]
    cell_size_string = str(cell_size) + 'arcsec'

    return cell_size_string, image_size
Ejemplo n.º 6
0
def runsdintimg(vis,
                sdimage,
                jointname,
                spw='',
                field='',
                specmode='mfs',
                sdpsf='',
                sdgain=5,
                imsize=[],
                cell='',
                phasecenter='',
                dishdia=12.0,
                start=0,
                width=1,
                nchan=-1,
                restfreq=None):
    """
    runsdintimg
    a wrapper around sdintimaging, D. Petry (ESO)
    
    vis - the MS containing the interferometric data
    sdimage - the Single Dish image/cube
             Note that in case you are creating a cube, this image must be a cube
             with the same spectral grid as the one you are trying to create.
    jointname - the imagename of the output images
    spw - the standard selection parameter spw of tclean
           default: '' i.e. all SPWs
    field - the standard selection parameter field of tclean
           default: '' i.e. all fields
    specmode - the standard tclean specmode parameter: supported are msf or cube
           default: msf 
    sdpsf - (optional) the SD PSF, must have the same coords as sdimage
           if omitted or set to '' (empty string), a PSF will be derived
           from the beam information in sdimage
    sdgain - the weight of the SD data relative to the interferometric data
           default: 5 
             'auto' - determine the scale automatically (experimental)
    imsize - (optional) the standard tclean imsize parameter 
            should correspond to the imagesize for the most extended
            interferometer config.
           default: determine from the input MS with aU.pickCellSize
    cell - (optional) the standard tclean cell parameter
            should correspond to the cell size for the most extended
            interferometer config, i.e. smallest beam / 5.
           default: determine from the input MS with aU.pickCellSize
    phasecenter - the standard tclean phasecenter parameter
           e.g. 'J2000 12:00:00 -35.00.00.0000'
           default: '' - determine from the input MS with aU.pickCellSize
    dishdia - in metres, (optional) used if no sdpsf is provided
           default: 12.0
    start - the standard tclean start parameter
             default: 0
    width - the standard tclean width parameter
             default: 1
    nchan - the standard tclean nchan parameter
             default: -1
    restfreq - the restfrequency to write to the image for velocity calculations
             default: None, example: '115.271GHz'

    Example: runsdintimg('gmc_120L.alma.all_int-weighted.ms','gmc_120L.sd.image', 
                'gmc_120L.joint-sdgain2.5', phasecenter='J2000 12:00:00 -35.00.00.0000', 
                 sdgain=2.5, spw='0', field='0~68', imsize=[1120,1120], cell='0.21arcsec')

    """

    if os.path.exists(vis):
        myvis = vis
    else:
        print(vis + ' does not exist')
        return False

    if os.path.exists(sdimage):
        mysdimage = sdimage
    else:
        print(sdimage + ' does not exist')
        return False

    mysdpsf = ''
    if sdpsf != '':
        if os.path.exists(sdpsf):
            mysdpsf = sdpsf
        else:
            print(sdpsf + ' does not exist')
            return False

    if specmode not in ['mfs', 'cube']:
        print('specmode \"' + specmode + '\" is not supported.')
        return False

    myia = iatool()

    myhead = imhead(mysdimage)
    myaxes = list(myhead['axisnames'])
    numchan = myhead['shape'][myaxes.index('Frequency')]

    print('Testing whether the sd image has per channel beams ...')
    myia.open(mysdimage)
    try:
        mybeam = myia.restoringbeam()
    except:
        myia.close()
        casalog.post('ERROR: sdimage does not contain beam information.',
                     'SEVERE',
                     origin='runsdintimg')
        return False

    haspcb = False
    if 'beams' in mybeam.keys():
        haspcb = True
        casalog.post("The sdimage has a per channel beam.",
                     'INFO',
                     origin='runsdintimg')

    myia.close()

    if not haspcb:
        os.system('rm -rf copy_of_' + mysdimage)
        os.system('cp -R ' + mysdimage + ' copy_of_' + mysdimage)
        if numchan == 1:
            # image has only one channel; need workaround for per-channel-beam problem
            myia.open('copy_of_' + mysdimage)
            mycoords = myia.coordsys().torecord()
            mycoords['spectral2']['wcs']['crval'] += mycoords['spectral2'][
                'wcs']['cdelt']
            myia.setcoordsys(mycoords)
            myia.close()
            tmpia = myia.imageconcat(
                outfile='mod_' + mysdimage,
                infiles=[mysdimage, 'copy_of_' + mysdimage],
                axis=3,
                overwrite=True)
            tmpia.close()
            mysdimage = 'mod_' + mysdimage
            numchan = 2

        myia.open(mysdimage)
        myia.setrestoringbeam(remove=True)
        for i in range(numchan):
            myia.setrestoringbeam(beam=mybeam,
                                  log=True,
                                  channel=i,
                                  polarization=0)
        myia.close()

        casalog.post(
            'Needed to give the sdimage a per-channel beam. Modifed image is in '
            + mysdimage,
            'WARN',
            origin='runsdintimg')

    # specmode and deconvolver
    if specmode == 'mfs':
        mydeconvolver = 'mtmfs'
    elif specmode == 'cube':
        mydeconvolver = 'hogbom'
        numchan = nchan

    scales = [0]

    mygridder = 'mosaic'

    # image and cell size
    npnt = 0
    if imsize == [] or cell == '':
        try:
            import analysisUtils as aU
        except:
            casalog.post(
                'Cannot import the analysisUtils. Set up your sys.path or provide imsize and cell.',
                'SEVERE',
                origin='runsdintimg')
            return False

        cell, imsize, npnt = aU.pickCellSize(myvis,
                                             spw=spw,
                                             imsize=True,
                                             cellstring=True)

    if phasecenter == '':
        phasecenter = npnt

    mythresh = '1mJy'  # dummy value
    mask = ''

    if restfreq == None:
        therf = []
    else:
        therf = [restfreq]

    os.system('rm -rf ' + jointname + '.*')

    sdintimaging(vis=myvis,
                 sdimage=mysdimage,
                 sdpsf=mysdpsf,
                 dishdia=dishdia,
                 sdgain=sdgain,
                 usedata='sdint',
                 imagename=jointname,
                 imsize=imsize,
                 cell=cell,
                 phasecenter=phasecenter,
                 weighting='briggs',
                 robust=0.5,
                 specmode=specmode,
                 gridder=mygridder,
                 pblimit=0.2,
                 pbcor=True,
                 interpolation='linear',
                 wprojplanes=1,
                 deconvolver=mydeconvolver,
                 scales=scales,
                 nterms=1,
                 pbmask=0.2,
                 niter=10000000,
                 spw=spw,
                 start=start,
                 width=width,
                 nchan=numchan,
                 field=field,
                 cycleniter=100,
                 threshold=mythresh,
                 restfreq=therf,
                 perchanweightdensity=False,
                 interactive=True,
                 mask=mask)

    print('Exporting final pbcor image to FITS ...')
    if mydeconvolver == 'mtmfs':
        exportfits(jointname + '.joint.multiterm.image.tt0.pbcor',
                   jointname + '.joint.multiterm.image.tt0.pbcor.fits')
    elif mydeconvolver == 'hogbom':
        exportfits(jointname + '.joint.cube.pbcor',
                   jointname + '.joint.cube.pbcor.fits')

    return True
Ejemplo n.º 7
0
            au.spwsforfield(field + '_all_split.ms.contsub', field=field))
        width = np.max([
            np.abs(
                au.effectiveResolution(field + '_all_split.ms.contsub',
                                       spw='{0}'.format(i),
                                       kms=True)) for i in range(count_spws)
        ])
        width = 0.2  #using the manual measurement instead of the above calculation because the latter is still somehow large.
        impars['width'] = '{0:.6f}km/s'.format(width)
        impars['restfreq'] = molepars[molepar]['restfreq']
        # calculate vstart
        vstart = u.Quantity(molepars[molepar]['vlsr']) - u.Quantity(
            molepars[molepar]['cubewidth']) / 2
        impars['start'] = '{0:.1f}km/s'.format(vstart.value)
        # calculate the dimension
        dim = au.pickCellSize(field + '_all_split.ms.contsub', imsize=True)
        impars['imsize'] = dim[1]
        impars['cell'] = ['{0:.2f}arcsec'.format(dim[0])]

        # creating the dirty image
        if not os.path.exists(
                os.path.join(imaging_root, field + '_' + band) + '_dirty_' +
                mole + '.residual'):
            print('making the dirty images')

            imagename = os.path.join(imaging_root,
                                     field + '_' + band) + '_dirty_' + mole
            os.system('rm -rf ' + imagename + '*')

            impars_dirty = impars.copy()
            impars_dirty['niter'] = 0