Giter VIP home page Giter VIP logo

auto_selfcal's Introduction

auto_selfcal

The goal of this code is to be able to run on an a set of ALMA or VLA *_targets.ms (or other MS files with the targets split out and having the same setup in each MS) files for single-pointing data and perform self-calibration using the continuum. If a cont.dat file is present, the code will flag the non-continuum regions and perform self-calibration on the continuum only.

To run this code with a concatenated calibrated_final.ms that one might receive from the NA ARC, one must split out the groups of SPWs associated with the individual observations, selecting on SPW, such that one has a set of MSes with SPWs that are all the same. For example, if an MS has SPWs 0,1,2,3,10,11,12,13, and 0,1,2,3 are from the first observation and 10,11,12,13 are from the second observation, they should be split out as follows:

split(vis='my_concat.ms',spw'0,1,2,3',outputvis='my_ms_0_targets.ms')
split(vis='my_concat.ms',spw'10,11,12,13',outputvis='my_ms_1_targets.ms')

This code can only be executed within the CASA 6.4+ environment, and is tested on CASA 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, and 6.5.0. CASA versions earlier that 6.4.0 are likely to encounter problems due to a gaincal bug that was fixed in CASA 6.4.0.

Standard ALMA and single-band VLA data are supported as are multiple targets. Multi-band VLA is supported. ALMA spectral scans may work, but have not been thoroughly tested. Mosaics have only had limited testing, but some limited functionality might work, specifically small mosaics where there is emission of the same source(s) within each pointing. Imaging will use nterms=2 for most VLA data and nterms=1 for most ALMA data. However, on a per-target basis, nterms=2 imaging will be used if S/N > 500, otherwise the full improvement possible from self-calibration may not be realized. Amplitude self-calibration will be attempted after phase-only self-calibration. If amplitude self-cal is not desired, set the variable 'do_amp_selfcal' to False in the auto_selfcal.py script.

Usage

  1. Create an empty directory

  2. Copy into this directory the *_targets.ms files that have identical setups (targets and spectral windows) to be self-calibrated (must contain only the targets desired for self-calibration and only TARGET observation intents)

  3. Copy auto_selfcal.py and selfcal_helpers.py into this directory (and regenerate_weblog.py if needed)

  4. Run script with

    mpicasa -n X casa -c auto_selfcal.py # X is the number of mpi threads to use.

    If serial operation is desired (without mpicasa), run with,

    casa -c auto_selfcal.py

    Alternatively, one could try it out using the modular casa6 packages in a custom Conda environment (see casa6.yaml)

    xvfb-run -d python auto_selfcal.py

The script will automatically find your *_targets.ms files, and determine all the parameters it needs for imaging and self-calibration of the science targets.

The script will output a file applycal_to_orig_MSes.py to apply the self-calibration solutions back to the original MS such that the line data can also have the self-calibration solutions applied.

The script will output a file uvcontsub_orig_MSes.py if a cont.dat file exists, excluding the same spectral regions for continuum fitting as were flagged for continuum self-calibration.

When finished summaries are generated for each target in weblog/index.html. Weblog generation may fail depending on what settings are cached for the viewer. If this is a problem you can remove all your cached casaviewer settings by running rm -rf ~/.casa/viewer. Then you can run casa -c regenerate_weblog.py, the regenerate_weblog.py script is included in the repository and only generates a new weblog from the already stored images and metadata pickle files.

Acknowledgements:

  • Certain functions to convert from LSRK to channel, S/N estimates, and tclean wrapper have their origins from the ALMA DSHARP large program reduction scripts.

  • The functions to parse the cont.dat file and convert to channel ranges (used the routine from above) was adapted from a function written by Patrick Sheehan @psheehan for the ALMA eDisk large program

auto_selfcal's People

Contributors

jjtobin avatar r-xue avatar psheehan avatar

Watchers

 avatar

auto_selfcal's Issues

Pipeline adaptation

To-Do List:

  • The workflow sequence and helper functions should be modularized so they can be easily used by Pipeline.
  • Fix the codestyle issue to avoid future problems.
  • Use Python/CASA logging for statements.
  • use the standard package/module file structure.
  • Ideally, the new restructured code can be used either in the Pipeline environment or as a "script" for the monolithic CASA:
    • To minimize the change to the original code, we could design a translating/adaptive layer to deal with externally developed scripts/modules in general. They are often/unfortunately written for the monolithic CASA (i.e. with the extra bits provided by casashell), rather than standard pythonic modules/class/functions. Under the proposed layer, the same namespace could present a "true" CASA task (when running as a script in CASA) or a Pipeline wrapper of a CASA task (when running as an "extern" dependency of Pipeline). Then external codes can be used in both contexts, without substantial rewriting.

Check List:

  • The refactored code should still work similarly to the original code in the "CASA script" mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.