NH3 Mapping Observations with the KFPA#
This tutorial walks you through the process of conducting a set of observations using the KFPA on the GBT. We will observe the first two inversion transitions of ammonia (J,K = 1, 1 and 2,2) towards the active star-forming region W51.
This tutorial assumes your scientific proposal has been accepted. It will then walk you through observational setup, observing, and data reduction providing a dataset ready for use in scientific analysis.
What you should already know
You need a GBO computing account. You should be relatively familiar with using a Linux command line, and starting AstrID.
You can find general instructions for using AstrID, as well as starting CLEO, contacting the operator, etc. here.
Data
The data we will be working with in this tutorial is taken from a set of observations of the RAMPS project. RAMPS observed a section of the Galactic Plane (40°>l>10°; b<|0.4°|) at frequencies including the ammonia (J,K = 1,1 and 2,2) inversion transition lines. These data are accessible at /home/scratch/lmorgan/Observer_Training/QuickGuides/KFPA/Data/RAMPS/RAMPS_W51.raw.vegas.
1 Starting Out#
Congratulations! Your scientific proposal to use the GBT has been accepted. You want to map the ammonia (J,K = 1,1 and 2,2) emission coming from the W51 active star-forming region. Now, your assigned project friend should reach out to you in plenty of time before the next observing semester starts to introduce themselves and offer any assistance that you may need in order to prepare for your observations. If you have not heard from your project friend yet and would like to take the initiative, you can find out who the project friend is either from your disposition notice (emailed out when your project is accepted) or by logging into the Dynamic Scheduling System (DSS) at dss.gb.nrao.edu. You will first need your NRAO proposal submission tool credentials to login.
2 Scripts and Configuration#
In order to perform observations with the GBT, you will write scripts using Python (currently v2.7). Normally, these scripts are written, saved and executed using the AstrID GUI. The full use and functionality of AstrID is covered elsewhere and will only be addressed here where it is specifically applicable to this particular project.
The first step we will follow in this guide is to establish general observing procedures. Scripts can then be constructed to carry out those procedures.
2.0 Calibration#
Good observing procedure in general is to first perform the necessary calibration scans for whatever set of observations is being undertaken, followed by the scientific observations themselves. When using the KFPA, what constitutes “necessary calibration” is not always straightforward. For calibration with the KFPA, at minimum the observer should point and focus the telescope (multiple times if necessary) and (usually) take a reference spectrum that is known to have emission at the frequency of interest. In this case, W51 is both the source we wish to map, as well as a known source of molecular ammonia emission so that it can be used for calibration purposes. It may be that your main science objective is to search for spectral lines that are not already well established, or that the source you are planning to map is not already known to be a source of emission in any of the lines you plan to observe. In these cases, creating a separate configuration which will tune for a spectral line that has been previously observed and/or choosing a separate source known to be a source of a line that you are able to observe would be a reasonable choice.
2.0.1 Point and Focus Script#
First we write a script that will point and focus the telescope using the KFPA receiver
with the command AutoPeakFocus().
1ResetConfig()
2
3config="""
4receiver = 'RcvrArray18_26'
5beam = 'All'
6obstype = 'Spectroscopy'
7backend = 'VEGAS'
8restfreq = 23694.5
9bandwidth = 23.44
10dopplertrackfreq = 23694.5
11nchan = 16384
12swmode = 'tp'
13swtype = 'none'
14swper = 1.0
15tint = 1.0
16vlow = 0
17vhigh = 0
18vframe = 'lsrk'
19vdef = 'Radio'
20noisecal = 'lo'
21pol = 'Circular'
22"""
23
24Configure(config)
25
26W51Source = Location('Galactic', 49.445, -0.35)
27AutoPeakFocus(source=None, location=W51Source)
28
- The individual components of this script are
-
-
ResetConfig()-
This command resets the configuration tool values to their defaults and helps to avoid carrying over any settings that the previous GBT observer may have made.
-
config = ""-
This configuration string, labelled
configis a set of parameters with their desired values that tell the system how you want to set up your observations. This will be covered in more detail shortly.
-
Configure(config) <astrid_commands.Configure()-
This command passes the parameter settings in the configuration string to the system itself and sets them. Strictly speaking, it is not necessary to configure the telescope before performing an
AutoPeakFocus(), as this command performs its own configuration. However, it can be useful to do so, to pre-empt potential issues, such as the wrong receiver (i.e. the receiver that was being used by the previous observer) being selected for observations by mistake.
-
W51Source = Location('Galactic', 49.445, -0.35)-
This defines the string “W51” as a
Location object, which contains the sky coordinates of the source to be observed. This could alternatively be read via aCatalog() <astrid_commands.Catalog()function, or input in a different coordinate system.
-
AutoPeakFocus()-
For this example, note that the first argument passed to
AutoPeakFocus()would be the actual source you want to perform the pointing/focus scans on. If you have a particular known source that you would like to use for this purpose, it can be supplied to the command using a catalog source orLocation object, similarly to theW51Sourceobject. For most observers, the actual source used for this purpose is unimportant, so long as the pointing/focus scans are successful and sensible. In this case, we supplyNoneas the first argument so thatAutoPeakFocus()will search for a source automatically. The second argument passed toAutoPeakFocus()is the location of the center point of the circle that it will use to search for a valid nearby pointing source. The defaults are that AutoPeakFocus will search for a source of at least 1.0 Jy within a radius of 10 degrees. If it is unable to find one, it will query the user on what they would like to do.
-
2.0.2 Spectral Line Calibration Observation Script#
Now that we have a pointing/focus script that will place the GBT itself in a good state for science observations, we similarly want to ensure that the backend system is also operating correctly.
1config="""
2receiver = 'RcvrArray18_26'
3beam = 'All'
4obstype = 'Spectroscopy'
5backend = 'VEGAS'
6restfreq = 23694.5, 23722.63
7bandwidth = 23.44
8dopplertrackfreq = 23694.5
9nchan = 16384
10swmode = 'tp'
11swtype = 'none'
12swper = 1.0
13tint = 1.0
14vlow = 0
15vhigh = 0
16vframe = 'lsrk'
17vdef = 'Radio'
18noisecal = 'lo'
19pol = 'Circular'
20"""
21
22Configure(config)
23
24W51Peak = Location('Galactic', 49.483, -0.358)
25W51Off = Location('Galactic', 49.483, 0.642)
26
27Slew(W51Off)
28Balance()
29OnOff(location=W51Peak,
30 referenceOffset=W51Off,
31 scanDuration=30.0,
32 beamName='1')
Note
There is no ResetConfig() command in this script - the only system settings that may have changed since running this for our Peak and focus script were made within that script and so are known to us.
The following commands in the script are
-
config=""-
As we are now planning to use the configuration as defined by this string, it is worthwhile to step through the relevant settings. The parameters particularly relevant to the observations in this guide are described.
-
receiver = 'RcvrArray18_26'-
Defines the receiver to be used.
'RcvrArray18_26'is the string used to identify the KFPA in the GBT system.
-
beam = 'All'-
The KFPA comprises seven usable beams, this parameter tells the system which of these seven beams we wish to collect data from.
-
restfreq = 23694.0, 23722.63-
The rest frequency or frequencies to be observed. This may be a list or defined as a dictionary. The potential range of inputs for this parameter is very large (and especially so for the KFPA) and can be complicated. Please seek assistance from GBT staff for spectral setups using the KFPA.
-
-
Configure(config)-
Passes the configuration settings to the system.
-
W51Peak = Location('Galactic', 49.483, -0.358)-
This is a slightly different sky position to the one defined as
W51Sourcein the peak and focus script. ThisW51Peakposition is the brightest point of the source in ammonia emission we will be mapping.
-
W51Off = Location('Galactic, 49.483, 0.642)-
This is the position to be used as the reference point for our position-switched observations. For spectral line observations where emission is not expected to be particularly widespread, it is common to simply use an offset of 1 degree, though care should be taken to ensure that this is emission-free.
-
Slew()-
This command moves the telescope to the commanded position.
-
Balance()-
This command adjusts power settings along the signal pathway to ensure that the system is operating within its optimal response regime for the given inputs. Note that we are balancing here while the telescope is pointed at our reference position. This is to ensure that most contributions to the system temperature (e.g. the atmospheric contribution, a function of elevation) will be similar to our actual observations while, when actually observing our source, we are adding power to the balanced level. Alternatively, we might balance while pointed at the source itself. However, in this case, we expect the source to be quite bright and so contribute significantly to the overall system temperature. By balancing “on-source”, we run the risk of underpowering the system when moving to our reference position. Severe differences in these levels will have impacts on data quality and should be avoided.
-
OnOff()-
This command performs the position-switched observation itself on the provided sky position, using the defined offset as the reference position. Note that we are explicitly using parameter names in this command (e.g.
location=W51Peak) while this is not strictly required. Users familiar with writing AstrID scripts may prefer to omit these labels. However, we are including them in this guide for clarity.
2.1 Mapping#
Assuming that the pointing/focus and spectral line reference observations proceed without issue, we will then want to proceed to our actual mapping observation. There are many different possible approaches to mapping with the GBT, each with different benefits and drawbacks. The approach followed here is to perform a long scan on a reference position, followed by the map itself, followed by another long scan on the same reference position. When deciding what procedure you should follow for your own projects, you should determine whether this would be a good scheme for your scientific goals. In this case, each integration of the map is essentially treated as a single position-switched observation. The benefit of this is that each integration has a large factor of “off” time compared to the “on” time and so signal-to-noise ratios will be improved. A drawback here is that, if the map takes too long to observe, then atmospheric conditions (which are often particularly significant in K-Band observations) may change significantly over the time it takes to complete the map and the “on” and “off” phases of parts of the map may not be well-matched in terms of their non-source system temperature contributions. If superior flux-calibration accuracy is important for your experiment, then it may be better for you to perform a RALongMapWithReference(), which performs an “off” observation every N rows or for you to use frequency-switching when mapping. GBO staff will be happy to advise you on these issues.
The following script shows the procedure to perform the actual science observations of this project.
1config="""
2receiver = 'RcvrArray18_26'
3beam = 'All'
4obstype = 'Spectroscopy'
5backend = 'VEGAS'
6restfreq = 23694.5, 23722.63
7bandwidth = 23.44
8dopplertrackfreq = 23694.5
9nchan = 16384
10swmode = 'tp'
11swtype = 'none'
12swper = 0.417
13tint = 0.834
14vlow = 0
15vhigh = 0
16vframe = 'lsrk'
17vdef = 'Radio'
18noisecal = 'lo'
19pol = 'Circular'
20"""
21
22Configure(config)
23
24W51Source = Location('Galactic', 49.445, -0.35)
25W51Off = Location('Galactic', 49.483, 0.642)
26
27Slew(W51Off)
28Balance()
29
30Track(location=W51Off,
31 endOffset=None,
32 scanDuration=30.0,
33 beamName='1')
34
35RALongMap(location=W51Source,
36 hlength=Offset('J2000', 15.6/60., 0.0, cosv=True),
37 vlength=Offset('J2000', 0.0, 12.48/60., cosv=True),
38 vDelta=Offset('J2000', 0.0, 12.91/3600., cosv=True),
39 scanDuration=120,
40 start=1,
41 stop=59)
42
43Track(location=W51Off,
44 endOffset=None,
45 scanDuration=30.0,
46 beamName='1')
Most of the features here have already been described, with the following exceptions and additions:
-
config=""-
A small change has been made to the
swperandtintparameters in the configuration string. Previously, these were both set to 1.0 s. For mapping, these need to be set so that they are consistent with the scanning speed, such that the map will be fully sampled. The full determination of these parameters is something that would be done at the time of proposal writing but, by using the GBT Mapping Calculator, a basic mapping command is easily constructed. By supplying the desired map sizes, along with the integration time (per beam), the mapping calculator will provide an example AstrID command which will produce a map with those parameters. In this case, an integration time of 0.834 s is needed in order to prevent “beam-smearing” as the telescope moves across the sky. In this example, we are using aswperwhich is a factor of two smaller than the integration time, effectively allowing us redundancy in the collection of our data - collecting two samples of data per integration.
-
W51Source = Location('Galactic', 49.445, -0.35)-
Note that we have returned to our original source coodinates from the pointing/focus script, this location is the center position of our map, rather than the brightest point as we used in the spectral line reference script.
-
Track-
A
Trackcommand follows the commanded position for the defined length of time, using the defined beam as the pointing center. This serves as our reference “off” position, taken before the map, with an identicalTrackscan performed following the map. Care should be taken to NOT balance between the reference and source scans.
RALongMap– The map we are taking has 59 rows which each take 120 s, totalling nearly two hours. This is at the upper end of how long one should observe at K-Band using the GBT without performing a pointing/focus observation. During stable conditions at night, this length of time may be acceptable. For daytime observations, observations which span dawn or dusk or less than ideal weather conditions, the map should be divided into blocks of no more than one hour, with pointing/focus scans performed in between. This is accomplished by, for example, taking thestart=1, stop=59inputs to our single mapping command and creating two new maps, the first havingstart=1, stop=29and the second havingstart=30, stop=59.
3 Observing#
To learn how to execute your observing scripts, please follow the GBT observations 101 guide. Here we show what would be expected to happen when carrying out the scripts described above.
3.0 Point and Focus#
Once this script is submitted, AstrID will reset all configuration parameters to their default values, configure for the provided configuration string and then search for an appropriate source near the target position. Once this is found, AstrID will perform four pointing scans, followed by a focus scan (assuming that there are no errors during this process). In the AstrID GUI the peak scans should resemble this
Note
The KFPA is a multi-beam receiver and, by default, uses data from two beams simultaneously to perform pointing scans. The two beams used for this are mounted on the telescope in a cross-elevation orientation, meaning that when azimuthal pointing scans are performed and the “reference” scan is removed from the “source” scan, a negative “dip” will be seen in the power output. This leads to the distinctive appearance of azimuth pointing scans when using multi-beam receivers on the GBT.
The focus scan should look like this
Assuming that the pointing and focus observations complete satisfactorily, the derived corrections will be applied to the telescope and you may proceed. If there is a failure along the way, often the best course of action is to resubmit the script and try again. If there is a reason not to do this (e.g. there has been a more significant software or hardware failure) then the operator will advise you. If you are unable to complete the pointing/focus scans after two or three attempts then it is likely that there is a problem with your script, the GBT itself or another system.
Some issues which have been encountered in the past include
-
- Pointing source too weak
-
AstrID will try to find a pointing source which is bright enough to provide a good pointing solution. However, in some cases, the source AstrID finds is simply not bright enough. If you suspect that this is the case, you can provide
flux = 2.0as an argument to the AutoPeakFocus() command to force AstrID to find a pointing source that is at least 2 Jy in flux. At K-Band, this should be more than adequate to complete a good set of pointing/focus scans.
-
- Trying to observe a source below the horizon
-
While it should not be possible to be scheduled at a time when your source is not visible in the sky, it has occasionally happened and can produce warnings/errors that are not completely obvious that this is what has happened. Please check the LST you are observing at against your source coordinates and make sure that you expect to be able to see your source.
If you do not see a reason for the failure of your pointing/focus observations, check with the operator and ask if they can see any obvious failures. While the operators are not responsible for guidance on your observations, they are familiar with the various telescope systems and will be able to identify any serious problems with the hardware. In the case that the operator can also not identify an obvious problem, it is time to call the on-call support scientist. The operator will know who this is at any given time and will be able to reach them. The on-call scientist will be able to advise you on how to proceed.
3.1 Spectral Line Calibration Observation#
After submitting this script, AstrID will set the commanded configuration parameters, slew to the commanded
off position and balance the system there. Observers should watch the AstrID output carefully here. The power
levels of VEGAS are considered to be in range if they are within 2 dB of -20 dB (see Monitoring VEGAS observations
is covered under “VEGAS Monitoring Tools” in the Observers Guide).
Outside of these values, the Balance() command may fail. There are also
other balancing failures that AstrID will report. However, AstrID will not necessarily stop a scan because
balancing has failed. This is by design as there are instruments which need to operate outside of the
standard balanced power ranges. It is worth a reminder here that data quality is primarily the
responsibility of the observer and you should be careful to monitor any and all error messages that are
passed through the AstrID window in the “Log” window. In the case that balancing errors are seen, the
Balance() command should be re-issued. It is rare that a
Balance() command fails multiple times in a row unless there is an issue
with the configuration. If you fail to achieve reasonable balanced power levels after two or three attempts,
you should contact the operator and ask for advice.
Assuming that the Balance() command has proceeded without issue, the
spectral line script will continue to perform an OnOff() scan pair on the
commanded position. This scan can be checked for data quality through the online capability of GBTIDL.
To start the GBTIDL software, go to a terminal window on a Green Bank Linux Machine (titania or ariel
ONLY if you are currently observing, another machine,
if you are not observing), and type
gbtidl
How you can access your data depends on if you are currently observing or not.
online
offline, 'AGBT24A_000_01'
Once you have successfully connected to your dataset, you can look at some basic metadata via
summary
This will show you a collection of basic information about the scans you have taken.
Note
There are several things to note about this summary of information.
This summary does not contain peak and focus scans. This is because the data taken by each backend are written to a different file and here GBTIDL is reading only the VEGAS file.
You may notice that the source scan numbers do not match what might be expected. If our observations had been run as described, the peak and focus scans would account for scan numbers 1-5, with the OnOff spectral line calibration scans beginning with scan number 6. In fact, the example dataset being used here was originally part of a large survey strategy and so there are differences in this aspect of the observations. This also accounts for the fact that our OnOff spectral line calibration scans have actually been performed on the source ‘L45OnOff’.
We can now examine the data taken in our spectral line reference scan using GBTIDL commands.
getps, 43
This will return the reduced spectrum for the position-switched scan pair of scans 43 and 44.
Note
By default, getps will show you the data for fdnum=0 (i.e. beam 1), ifnum=0 (i.e. the first input rest frequency) and plnum=0 (i.e. the left-hand circularly polarized channel).
Todo
Show the resulting spectrum.
Note
In order to achieve a high signal-to-noise ratio for these data both polarizations have been averaged and the spectrum has been smoothed by 12 channels).
Todo
Add all commands required to achieve this.
The ammonia spectrum is clearly visible, which gives us confidence that our configuration, telescope pointing and power levels are all within reasonable limits. A final further assurance of the data quality of our observations can be found by noting the system temperature, given in the top right corner of the GBTIDL data plotter window. A good range for the system temperature of the KFPA is ~30 - 45 K. Here we see that we have a system temperature of 35.0 K. This implies that everything is running smoothly and we have good observing conditions.
3.2 Mapping#
After submitting the mapping script, AstrID will set the commanded configuration, slew to the commanded ‘off’ position and balance the system. Following a successful balance, the off position will be observed via the Track command for 30 s. Then the RALongMap procedure will be followed until completion, at which point another 30 s track scan on the off position will be observed.
It is not always obvious how best to monitor data quality while mapping. Assuming that the ‘online’ mode of GBTIDL is being used, mapping scans will become accessible shortly after each scan row is completed, throughout the observing session. There is no standard capability provided for users to produce ‘quick look’ maps during the observing process. In order to determine the health of ongoing observations, users should continue to monitor the VEGAS power levels, as well as the system temperatures reported in CLEO and GBTIDL.
It is, of course, possible to examine the spectral data in near ‘real-time’ as data are collected. Running the command
getsigref, 78, 77
This will return a spectrum which has been processed with the first row of our map taken as the ‘on’ portion of a position-switched observation, using our actual ‘off’ for the reference portion. This will allow us to maintain a general overview of the data being collected (monitoring system temperature, etc). However, we are unlikely to see spectral line emission in most circumstances using this command. This is because the entire row of our map is being averaged for the ‘on’ position, which will result in low signal-to-noise, even if significant spectral line emission is present at some positions within that row. It is also possible to reduce spectra for individual integrations within a scan row. However, it is not necessarily straightforward to determine which integrations are likely to contain emission, even if the relevant sky coordinates are known.
4 Data Reduction (Basic)#
The following section is currently under construction. Users are welcome to read, but please keep in mind that formatting and/or information will be changed imminently. Thank you!
This section is intended to outline the process of reducing a set of observations with the GBT, focusing on using the K-Band Focal Plane Array (KFPA) to observe transitions of the ammonia molecule in an active star-forming region designated as W51. The relevant dataset has been taken from the RAMPS survey (Hogge, et al. 2018). This section will mainly be concerned with a straightforward reduction of the data in a standard manner. Where it is possible to improve data quality by utilizing special techniques, these will be covered in supplementary material. Aspect of the observations which are more general, such as performing pointing and focus scans, will only be addressed insofar as the relate directly to the receiver and observing constraints in question.
It is expected that the user is familiar with the previous content of the KFPA Observing Guide. This sets out the process of preparing and conducting a single session of mapping observations. Specifically, the dataset used in that example is the same as the one used here.
4.0 Data Setup#
The data used for example purposes comes from the RAMPS survey. Specifically, a map which covers the region 49.29° – 49.59°, -0.23° – -0.47° in Galactic longitude and latitude. The strategy of the RAMPS survey was to produce tiles of many small regions, which were later stitched together.
In the case presented here, we are interested in a region centered at coordinates of 49.445, -0.35. This was observed as part of RAMPS with the project ID of AGBT16A_353, in session 39. Retrieving the data would normally involve the process of using the GBT Help Desk; however, for the purpose of following this guide, an sdfits file has been created for this exercise.
This example assumes the user will be using GBTIDL for data reduction which can only be used on the GBO network. Thus you will need to have a GBO computing account and connect remotely.
4.0.1 Setting the Work Directory#
Once connected to the GBO network, navigate to the directory that will house all related files to this example.
Use cd to navigate to and take note of your working directory:
cd /path/to/your/working_directory
All commands in this example assumes that you are operating out of your designated working directory. If you must revisit this example, ensure that you return to the same working directory before resuming work.
4.0.2 Accessing the Data#
The next step is to copy the target data and place it in your working directory. There are multiple methods to complete this task. For the purposes of this example, the intended target file can be found at:
cd /home/dataproducts/training_data/RAMPS_W51.raw.vegas
Note
‘RAMPS_W51.raw.vegas’ is a select data set of ‘AGBT16A_353_39’, which is much too large for the purposes of this example.
To work with the data, it must now be copied to your working directory. There are multiple methods to complete this task. Choose the method that works best for your case. Two such methods include:
From within your working directory, make a symlink to the data with the following command:
ln -s /home/dataproducts/training_data/RAMPS_W51.raw.vegas
From any directory, copy the data directly to your working directory with the following command:
rsync -avz /home/dataproducts/training_data/RAMPS_W51.raw.vegas
From any directory, copy the data directly to your working directory with the following command:
rsync -avz /home/dataproducts/training_data/RAMPS_W51.raw.vegas.tar
Then while in your working directy, untar the data via:
tar -xzf RAMPS_W51.raw.vegas.tar
Todo
Determine if data (tarred or not) is acquirable via ‘’wget’’.
Additionally, the Astrid log of the session (in the form of a .txt file) can be retrieved, if desired, via:
getastridlog AGBT16A_353_39
From this log and the information given in the KFPA Observing Guide, we find the configuration statements used for these observations, as well as the relevant scan numbers. As in the KFPA Observing Guide, we can view the summary of the dataset by reading in the data with GBTIDL.
Start up GBTIDL at the command line, read in the data, and check the file contents via:
gbtidl ; starts up gbtidl
filein, 'RAMPS_W51.raw.vegas' ; loads in the dataset
summary ; lists basic metadata
The summary output should look like:
Note
This should be the same summary output as the summary output in 3.1 Spectral Line Calibration Observation.
We can see that scans 43 and 44 are a position-switched scan pair of a calibration source. Scans 76 and 104 are reference scans of the off position. Scans 77 – 103 are a sequence of mapping scans.
4.1 GBTIDL Setup Commands#
In this section, there will be multiple commands that will have to be combined in the next section (4.2 Data Reduction). Clearing the memory buffer for a clean slate will be a part of the reduction, so this section grants a bit of freedom to experiment and get comfortable with GBTIDL Plotter.
4.1.1 Calling Scans#
A straightforward reduction of a single map ‘stripe’ can be achieved via:
getsigref, 80, 76 ; 80 is on source, 76 is off (ref) source
This will open a new window for GBTIDL Plotter to display the designated spectrum.
Note that this defaults to the first ‘ifnum’ of the scan, the first beam, and the first polarization. The first rest frequency, in our case, is the rest frequency of the ammonia (1, 1) transition at 23.6945 GHz. Furthermore, it is using the entire scan as the ‘On’ in a position-switched reduction. This means that a whole strip of the map is contributing to the resulting spectrum.
This will result in a scan that looks like:
Note
GBTIDL may default the x-axis to “LSR Frequency (GHz)”. Select the “GHz” button at the top of the GBTIDL Plotter window, and select “km/s” from the dropdown. This will set the x-axis to ‘LSR Velocity (km/s) RADIO’.
Now that scans can be loaded into GBTIDL, our next step is to use GBTIDL Plotter to manipulate our data.
4.1.2 Temperature Scaling#
A remaining factor to account for is the temperature scale we wish our spectra to be calibrated on. By default, GBTIDL presents spectra on the antenna temperature (Ta) scale. In order to convert this scaling to flux density (Jy) or corrected antenna temperature (Ta*), it is necessary to account for the sky opacity. The approach to determining this is outlined in the Sky Opacity Guide. For the example presented here, we find a sky opacity tau value of 0.03.
Todo
Insert Sky Opacity Guide link.
We can now scale to the corrected antenna temperature (Ta*) scale via:
getsigref, 80, 76, units='Ta*', tau=0.03
Note
Care must be taken here to include a tau value. If the previous command is run without specifying tau, a default ‘representative’ value is used (0.032 in this case). This could potentially result in poorly calibrated data.
Note that scaling to a main beam temperature scale from the corrected antenna temperature requires only a simple scalar division by the beam efficiency factor. For KFPA observations at 23.7 GHz, this is eta_mb ~0.89 and can be measured from calibration observations or estimated from information given in the GBT Proposers Guide.
Todo
Insert GBT Proposers Guide link
4.1.3 Smoothing a Single Polarization#
Note that the goal for the velocity resolution of the RAMPS survey is 0.2 km/s per channel. Having loaded our spectrum via the ‘’getsigref’’ command, we can now access the data structure !g, which contains information we might normally expect to find in a FITS file header. The !g idl structure itself is a general container and the !g.s[0] structure relates directly to the spectral data.
Printing the native resolution of the observed data can be done via:
print, !g.s[0].frequency_resolution
This shows that the native resolution of the observed data is 1430.5115 Hz. At 23.694 GHz, this is the equivalent to a velocity difference of 0.0181 km/s and we must smooth to the requisite resolution of 0.2 km/s.
We can apply a smoothing kernel over 11 channels via:
gsmooth, 11
This results in a spectrum that looks like:
An indication of some emission may be seen at around velocity of 58 km/s. Remember that this spectrum represents a whole 0.26° stripe and so any localized areas of emission will be ‘washed out’ by the rest of the stripe.
4.2 Data Reduction#
The following section will be a combination of previously learned commands + new commands to prepare our data for GBTGridder.
4.2.1 Reducing a Single Integration#
In order to find the spectrum of a single position in our map, we want to reduce the data for a single integration via the use of the parameter ‘intnum’. In order to retrieve all of the information for that position, we would want to average the two observed polarizations, as well as the data from each beam.
Averaging the polarizations can be achieved via:
sclear ; ensures that the memory buffer is cleared
getsigref, 80, 76, intnum=50, plnum=0, fdnum=0, units='Ta*', tau=0.03 ; calls the first polarization
accum ; loads the spectrum into the memory buffer
getsigref, 80, 76, intnum=50, plnum=1, fdnum=0, units='Ta*', tau=0.03 ; calls the second polarization
accum ; loads the spectrum into the memory buffer
ave ; averages the two spectra together
gsmooth, 11 ; applies smoothing kernel over 11 channels
This results in a spectrum that looks like:
Emission can clearly be seen centered at ~57 km/s.
It should be noted that averaging data from multiple beams at this point is not beneficial. For a given scan/integration, the beams are at different positions on the sky; therefore, averaging their data together would not be representative of a single sky position. Because of this, it is sensible to reduce the data for each beam individually and then combine them via an overall gridding procedure.
With this in mind, it should also be noted that the approach here is to reduce the map integration-by-integration, producing files which can then be fed into the gbtgridder routine, which will produce the final cube. As such, some decisions need to be made at this point, such as whether the individual polarizations should be averaged at the beginning, or output separately so that they can be averaged by the gridder. For the purposes of illustration, we keep the polarizations separate here. This is generally good practice as issues which may affect data quality (e.g. RFI or instrumentation failure) are often associated with a single polarization. If any such issues arise, having the data separated into different polarizations can facilitate more granular inspection and allow for flagging of poor data.
4.2.2 Baseline Removal#
One thing yet to be done is removing the baseline level. As we do not (necessarily) know in advance what the expected velocity range of any emission in the map might be, it makes sense to initially remove a low order polynomial over the entire spectral range. By using a low factor polynomial (e.g. 2), we avoid fitting to any potential emission. Although, we should avoid including the band edges where it can be seen that power tapers off. This might have unwanted effects on the baseline fitting. The user can interactively click on the spectrum edges and set the region to be fitted.
An initial estimate of the region can be fitted via:
setregion
Use the green crosshair to set the x-axis boundaries of the region by left clicking on each end of the spectrum. Take care to avoid where the power tapers off at the edges of the band. Save your selections and exit the function by right clicking. Your region should look similar to the image below:
Once this is done, the relevant channel numbers can be retrieved via:
print, !g.regions[0:1] ; this assumes that only a single region is set
Manually setting a region will cause the numbers to vary from user to user. For the purposes of this example, we will use the channel numbers 589 and 15854.
Now that the region is defined, the polynomial factor can be applied, and the fitted baseline inspected via:
nregion, [589, 15854] ; sets the defined region
nfit, 2 ; sets the baseline polynomial factor of 2
bshape ; allows user to inspect fitted baseline shape before removal
This results in plotted features like:
The actual removal of the baseline is achieved via:
baseline
Note again that we are not attempting to remove any ‘wiggly’ baseline shape at this step, merely calibrating the spectra to the same overall level by removing any broad excess/deficit power level. For most projects which do not require particularly high calibration precision, this will likely be adequate for a final science product. If more precision is necessary, this should be an iterative step in which emission is identified and velocity ranges set more carefully so that higher-order polynomial baseline shapes can be fitted and removed. This must be done for each beam and polarization, a total of 14 individual instances in the case of KFPA when using all beams and dual polarizations (as in this example)
4.3 Batch Reduction#
At this point, we have applied scaling to the Ta* scale and found acceptable ranges and polynomial order for the baseline fit. Now we are ready to reduce our data integration-by-integration and output them into files which can then be fed into gbtgridder.
Outputting the files is achieved by:
fileout, 'W51_Map_Beam00_plnum0_ifnum0.fits',/new ; opens new file for writing; '/new' is a flag to overwrite existing files of the same name
keep ; writes spectral data container contents to the file
A complete initial data reduction of an individual feed/polarization/frequency, with the production of a file containing the reduced data can be done in a single script. This requires a procedure to be written and loaded into GBTIDL. Using bash in another terminal window, create a procedure/program (.pro) file using your preferred text editor.
In a new terminal window, create a procedure file via:
vim ramps_w51.pro
You may use your preferred text editor. Whichever is used, name the file ‘ramps_w51.pro’ for the purposes of this example.
The procedure can be formatted to reduce a single beam and polarization per script or all 14 permutations of the 7 beams (fdnum=0,6) and 2 polarizations (plnum=0,1) in a single script. Only a single spectral window will be used (ifnum=0).
This procedure will only reduce a single beam/polarization and must be altered to produce the rest of the fits files. Ensure that the output file name is appropriately changed as to not overwrite the previous permutation’s data.
pro ramps_w51
sclear
filein, 'RAMPS_W51.raw.vegas'
first_scan = 77
last_scan = 103
off_scan = 76
n_ints = 126 ; as seen in the summary information
fileout,'W51_Map_Beam00_plnum0_ifnum0.fits',/new ; change name to match beam/pol
for scan=first_scan,last_scan do begin
for int=0,n_ints-1 do begin ; change plnum (0,1) and fdnum (0,6) as needed
getsigref,scan,off_scan,intnum=int,plnum=0,ifnum=0,fdnum=0,units='Ta*',tau=0.03
nregion,[589,15854]
nfit,2
baseline
gsmooth,11
keep
endfor
endfor
end
This simple procedure may then be run for each required feed, polarization, and rest frequency. The benefits of this method is that multiple procedures can be written to the same working direcotry but ran in different terminal windows at different times. This provides more flexibility as the data is reduced.
This procedure will reduce all beams and polarizations and create individual fits files for each permutation. This will take significantly longer than the single beam/polarization method. Be mindful of when, where, and on what machine you run this procedure.
pro ramps_w51
sclear
filein, 'RAMPS_W51.raw.vegas'
first_scan = 77
last_scan = 103
off_scan = 76
n_ints = 126 ; as seen in the summary information
for fdnum=0,6 do begin
for plnum=0,1 do begin
outfile = string(fdnum, plnum, ifnum, format='("W51_Map_Beam",I02,"_plnum",I0,"_ifnum0.fits")')
fileout,outfile,/new
for scan=first_scan,last_scan do begin
for int=0,n_ints-1 do begin
getsigref,scan,off_scan,intnum=int,plnum=plnum,ifnum=0,fdnum=fdnum,units='Ta*',tau=0.03
nregion,[589,15854]
nfit,2
baseline
gsmooth,11
keep
endfor
endfor
endfor
endfor
end
Note
Take note that in IDL, comments begin with a semicolon (;), not a pound sign (#). Any script intended to be used in GBTIDL must follow this rule.
Ensure that your procedure file is stored in your working directory. Go back to your terminal window with GBTIDL open, then load it in with the following commands:
.compile ramps_w51.pro ; compiles the most recent version of the procedure into GBTIDL
ramps_w51 ; runs the procedure
Allow GBTIDL the time to fully run through our procedure. It is important that intended input files contain only the desired parameters, as GBTGridder does not have the capability to distinguish frequency or polarization in its input files. If scans of multiple frequencies were included, for example, GBTGridder would blindly grid all values, blending together emission from those frequencies. By outputting individual files for each feed/polarization/frequency, inputs to GBTGridder can be more carefully controlled.
For more information about how to write and use your own procedures in GBTIDL, visit the ‘Writing Your Own Procedures’ page on GBTDocs.
Todo
Insert link to ‘Writing Your Own Procedures’ page on GBTDocs.
4.4 Gridding and Imaging#
4.4.1 GBTGridder#
For those new to gbtgridder, basic descriptions of usage syntax, with input arguments, can be found on any GBO computer via:
gbtgridder -h
In a new terminal, we are going to run gbtgridder with the following:
gbtgridder -k gaussbessel --clobber --mapcenter 49.445 -0.35 --size 125 109 -c 1577:9866 --pixelwidth 9 -p TAN -o W51_IFNUM0 W51_Map_Beam0?_plnum?_ifnum0.fits --noweight --autoConfirm
Now let’s break down what this does:
-
- gbtgridder
-
Starts up gbtgridder.
-
- -k gaussbessel
-
Specifies the gridding kernel used. A Gauss/Bessel function most accurately represents the GBT beam and is likely the most appropriate choice for fully-sampled data.
-
- –clobber
-
Tells gbtgridder to overwrite any output files which may already exist.
-
- –mapcenter 49.445 -0.35
-
Defines the central coordinates of the map. In most cases, gbtgridder will find and set these by default. However, in some cases (e.g. if a map covers a Galactic longitude of 180°), gbtgridder may struggle to recover reasonable values. It can be slightly less computationally intensive to define the coordinates, especially if gbtgridder is going to be run multiple times.
-
- –size 125 109
-
Defines the x/y sizes of the output cube. Again, gbtgridder will usually process and set these values by default, but explicitly setting them can save calculation time and safegaurd against unconstrained parameters.
-
- -c 1577:9866
-
Sets the channel range that will be gridded into the output cube. Note that this range will be relevant to the data being input in gbtgridder. It is important here to note if the ‘/decimate’ flag was passed to the ‘gsmooth’ command when the data was smoothed. If so, these channel numbers will be different by an equivalent factor from the raw data.
-
- –pixelwidth 9
-
Defines the width of a pixel on the sky in arcseconds. A value roughly equivalent to 1/3 of the observed beamwidth is typical.
-
- -p TAN
-
The sky projection used for the output files.
-
- -o W51_IFNUM0
-
The prefix used for output files.
-
- W51_Map_Beam0?_plnum?_ifnum0.fits
-
The input files to gbtgridder, given without a parameter flag. The ‘?’ serves as a wildcard (similar to ‘*’ but for a single character). GBTGridder will attempt to grid all data put into it; therefor, it is very important only intended data is covered by the file string.
-
- –noweight
-
Prevents gbtgridder from creating a file containing the weights used when gridding.
-
- –autoConfirm
-
Allows gbtgridder to proceed with the actual gridding without waiting for the user to confirm the input parameters once the input files are read.
This should result in a new file called ‘W51_IFNUM0_cube.fits’ in your working directory. Having run this command… congratulations! You now have a fully reduced data cube.
4.4.2 Moment 0 Map#
Having run gbtgridder, we now have a data cube with two spatial axes (Galactic longitude and Galactic latitude) and one spectral axis. To see where the emission is on the sky, we can collapse the spectral axis into a single image. This is called a moment 0 map. It adds up the intensity in each velocity channel across a chosen range, weighted by the channel width, giving the total line emission at every position. The resulting units are K km/s.
You are free to use whatever method of generating a moment 0 map that you are most comfortable with. This example will use the Python packages ‘spectral-cub’’, ‘astrop’’, ‘matplotlib’, and ‘numpy’.
Todo
Include alternative imaging methods (e.g. CASA).
If you do not already have these packages available to you, install via:
pip install spectral-cube astropy matplotlib numpy
Once installed, open a Python script or Jupyter notebook to create the moment 0 script.
from spectral_cube import SpectralCube # handles 3D cubes
import astropy.units as u # attaches units (e.g. km/s) to numbers
import matplotlib.pyplot as plt
import numpy as np
cube = SpectralCube.read('W51_IFNUM0_cube.fits') # "StokesWarning" is normal - keeps I component
cube = cube.with_spectral_unit(u.km/u.s, velocity_convention='radio') # converts spectral axis to velocity (K km/s)
sub = cube.spectral_slab(45*u.km/u.s, 75*u.km/u.s) # chosen velocity range - based on spectrum plot
mom0 = sub.moment(order=0, how='slice') # sum emission / velocity (one channel at a time)
mom0.write('W51_IFNUM0_mom0.fits', overwrite=True)
vmin, vmax = np.nanpercentile(mom0.value, [1, 99.9]) # color limits 1st -- 99.9th percentile - avoids washing out
# builds and displays plot
fig = plt.figure(figsize=(8, 7))
ax = fig.add_subplot(111, projection=mom0.wcs)
im = ax.imshow(mom0.value, origin='lower', vmin=vmin, vmax=vmax, cmap='jet')
fig.colorbar(im, ax=ax, label='K km/s')
ax.coords[0].set_axislabel('Galactic longitude (deg)')
ax.coords[1].set_axislabel('Galactic latitude (deg)')
ax.coords[0].set_major_formatter('d.dd')
ax.coords[1].set_major_formatter('d.dd')
plt.show()
Now, having run this script… congratulations again! You now have an integrated (moment 0) map of the spectral data cube.
Depending on your imaging method, your map should resemble the image below:
This concludes a basic data reduction procedure for the KFPA receiver. A more complex guide will follow for advanced users.