- Timestamp:
- 03/31/06 17:40:57 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/cookbook.tex
r953 r966 58 58 \begin{verbatim} 59 59 > cd /my/data/directory 60 > asap 260 > asap 61 61 \end{verbatim} 62 62 … … 341 341 \label{sec:selection} 342 342 343 CHRIS TOFILL IN 344 345 %You can copy one scantable to another with the \cmd{copy} function. 346 347 %Example: 348 349 %\begin{verbatim} 350 % ASAP> scans = scantable('MyData.rpf') 351 % ASAP> scan2 = scans.copy() 352 %\end{verbatim} 343 ASAP contains flexible data selection. Data can be selected based on 344 IF, beam, polarisation, scan number as well as values such as 345 Tsys. Advanced users can also make use of the AIPS++ TAQL language to 346 create selections based on almost any of the standard header values. 347 348 Selection is based on a \cmd{selector} object. This object is created 349 and various selection functions applied to it (\cmd{set\_ifs}, 350 \cmd{set\_beams} etc). The selection object then must be applied to a 351 scantable using the \cmd{set\_selection} function. A single selection 352 object can be created and setup then applied to multiple scantables. 353 354 Once a selection has been applied, all following functions will only 355 ``see'' the selected spectra (including functions such as 356 \cmd{summary}). The selection can then be reset and all spectra are 357 visible. Note that if functions such as \cmd{copy} are run on a 358 scantable with active selection, only the selected spectra are copied. 359 360 The common selection functions are: 361 362 \begin{itemize} 363 364 \item[\cmd{set\_beams}] Select beams by index number 365 \item[\cmd{set\_ifs}] Select ifs by index number 366 \item[\cmd{set\_name}] Select by source name. Can contain ``*'' as a 367 wildcard, e.g. ``Orion*\_R''. 368 \item[\cmd{set\_ifs}] Select ifs by index number 369 \item[\cmd{set\_polarisation}] Select but polarisation index or 370 name. If polarisation names are given, the data will be on-the-fly 371 converted (for example from linears to Stokes). Not all conversions 372 are currently supported. 373 \item[\cmd{set\_query}] Set query directly. For power users only! 374 \item[\cmd{set\_tsys}] Select data based on Tsys. Also example of user 375 definable query. 376 \item[\cmd{reset}] Reset the selection to include all spectra. 377 378 379 Note that all indices are zero based. 380 381 Examples: 382 383 \begin{verbatim} 384 385 \end{verbatim} 386 ASAP> selection = selector() # Create selection object 387 ASAP> selection.set_ifs(0) # Just select the first IF 388 ASAP> scans.set_selection(selection) # Apply the selection 389 ASAP> print scans # Will just show the first IF 390 391 ASAP> selection.set_ifs([0,1]) # Select the first two IFs 392 ASAP> selection.set_beams([1,3,5]) # Also select three of the beams 393 ASAP> scans.set_selection(selection) # Apply the selection 394 395 ASAP> selection.set_name('G308*') # Select by source name 396 397 ASAP> selection.reset() # Turn off selection 398 ASAP> scans.set_selection(selection) # Apply the reset selection 399 400 \end{itemize} 353 401 354 402 \subsection{State} … … 437 485 \subsubsection{Masks} 438 486 439 \index{Masks}\index{Scantable!masks}Many tasks (fitting, baseline 440 subtraction, statistics etc) should only be run on range of 441 channels. Depending on the current ``unit'' setting this range is set 442 directly as channels, velocity or frequency ranges. Internally these 443 are converted into a simple boolean mask for each channel of the 444 abscissa. This means that if the unit setting is later changed, 445 previously created mask are still valid. (This is not true for 446 functions which change the shape or shift the frequency axis). You 447 create masks with the function \cmd{create\_mask} and this specified 448 the channels to be included in the selection. 449 450 When setting the mask in velocity, the conversion from velocity 451 to channels is based on the current cursor setting, selected row and 452 selected frequency reference frame. 487 \index{Masks}\index{Scantable!masks} 488 489 Many tasks (fitting, baseline subtraction, statistics etc) should only 490 be run on range of channels. Depending on the current ``unit'' setting 491 this range is set directly as channels, velocity or frequency 492 ranges. Internally these are converted into a simple boolean mask for 493 each channel of the abscissa. This means that if the unit setting is 494 later changed, previously created mask are still valid. (This is not 495 true for functions which change the shape or shift the frequency 496 axis). You create masks with the function \cmd{create\_mask} and this 497 specified the channels to be included in the selection. When setting 498 the mask in velocity, the conversion from velocity to channels is 499 based on the current cursor setting, selected row and selected 500 frequency reference frame. 501 502 503 Note that for multi IF data with different number of channels per IF a 504 single mask cannot be applied to different IFs. To use a mask on such 505 data the selector should be applied to select all IFs with the same 506 number of channels. 453 507 454 508 Example : … … 998 1052 ASAP> selection = selector() 999 1053 # Select second IF 1000 ASAP> selection.set_if (1)1054 ASAP> selection.set_ifs(1) 1001 1055 ASAP> plotter.set_selection(selection) 1002 1056 1003 1057 # Select first 4 beams 1004 ASAP> selection.set_beam ([0,1,2,3])1058 ASAP> selection.set_beams([0,1,2,3]) 1005 1059 ASAP> plotter.set_selection(selection) 1006 1060 … … 1010 1064 1011 1065 # Multiple selection 1012 ASAP> selection.set_if (1)1066 ASAP> selection.set_ifs(1) 1013 1067 ASAP> selection.set_scans([2,4,6,10]) 1014 1068 ASAP> plotter.set_selection(selection) … … 1083 1137 available. This is done by creating a fitting object, setting up the 1084 1138 fit and actually fitting the data. Fitting can either be done on a 1085 single scantable row/cursor selection or on an entire scantable using 1086 the \cmd{auto\_fit} function. 1139 single scantable selection or on an entire scantable using the 1140 \cmd{auto\_fit} function. If single value fitting is used, and the 1141 current selection includes multiple spectra (beams, IFs, scans etc) 1142 then the first spectra in the scantable will be used for fitting. 1087 1143 1088 1144 \begin{verbatim} … … 1090 1146 ASAP> f.set_function(gauss=2) # Fit two Gaussians 1091 1147 ASAP> f.set_scan(scans) 1092 ASAP> scans.set_cursor(0,0,1) # Fit the second polarisation 1148 ASAP> selection = selector() 1149 ASAP> selection.set_polarisation(1) # Fit the second polarisation 1150 ASAP> scans.set_selection(selection) 1093 1151 ASAP> scans.set_unit('km/s') # Make fit in velocity units 1094 1152 ASAP> f.fit(1) # Run the fit on the second row in the table … … 1175 1233 1176 1234 Conversions of linears to Stokes or Circular polarisations are done 1177 ``on-the-fly''. Leakage cannot be corrected for nor are the se routines1178 ableto calibrate position angle offsets.1235 ``on-the-fly''. Leakage cannot be corrected for nor are there routines 1236 to calibrate position angle offsets. 1179 1237 1180 1238 \subsection{Simple Calibration} … … 1239 1297 ASAP> selection = selector() 1240 1298 1241 ASAP> selection.set_polarisations([``I '', ``Q'', ``U'', ``V''])1299 ASAP> selection.set_polarisations([``I Q U V'']) 1242 1300 ASAP plotter.set_selection(selection); # Select I, Q, U \& V 1243 1301 1244 ASAP> selection.set_polarisations([``I '', ``Q'')1302 ASAP> selection.set_polarisations([``I Q'') 1245 1303 ASAP plotter.set_selection(selection); # Select just I \& Q 1246 1304 1247 ASAP> selection.set_polarisations([``RR '', ``LL'')1305 ASAP> selection.set_polarisations([``RR LL'') 1248 1306 ASAP plotter.set_selection(selection); # Select just RR \& LL 1249 1307 1250 ASAP> selection.set_polarisations([``XX '', ``YY'')1308 ASAP> selection.set_polarisations([``XX YY'') 1251 1309 ASAP plotter.set_selection(selection); # Select linears 1252 1310 1253 ASAP> selection.set_polarisations([``I'', ``Plinear'') 1254 ASAP plotter.set_selection(selection); # Select linears 1311 ASAP> selection.set_polarisations([``I Plinear'') 1312 ASAP plotter.set_selection(selection); # Fractional linear 1313 1314 [[MALTE: This does not work]] 1315 1316 ASAP> selection.set_polarisations([``Pangle'') 1317 ASAP plotter.set_selection(selection); # Position angle 1255 1318 1256 1319 \end{verbatim} … … 1270 1333 ASAP> scans.save('myscan.sdfits', 'SDFITS', stokes=True) 1271 1334 \end{verbatim} 1272 1273 1335 1274 1336 \section{Scantable Mathematics} … … 1280 1342 not work for integers). 1281 1343 1282 \begin{verbatim} 1283 ASAP> sum = scan1+scan2 1344 {\em Currently mathematics between two scan tables is not available } 1345 1346 \begin{verbatim} 1347 % ASAP> sum = scan1+scan2 1284 1348 ASAP> scan2 = scan1+2.0 1285 1349 ASAP> scan *= 1.05 … … 1344 1408 plotter.plot(q) 1345 1409 1346 # Velocity align the data before averaging1410 # Set reference frame 1347 1411 q.set_unit('km/s') 1348 1412 q.set_freqframe('LSRK') 1349 q.freq_align() 1350 1351 # Average all scans in time 1352 av = q.average_time() 1413 1414 # Average all scans in time, aligning in velocity 1415 av = q.average_time(align=True) 1353 1416 plotter.plot(av) 1354 1417 … … 1400 1463 def xyscale(data,xtsys=1.0,ytsys=1.0,nomtsys=25.0) : 1401 1464 1402 data.set_cursor(pol=0) 1403 data.scale(xtsys/nomtsys,allaxes=False) 1404 1405 data.set_cursor(pol=1) 1406 data.scale(ytsys/nomtsys,allaxes=False) 1407 1408 data.set_cursor(pol=2) 1409 data.scale((xtsys+ytsys)/(2*nomtsys),allaxes=False) 1410 1411 data.set_cursor(pol=3) 1412 data.scale((xtsys+ytsys)/(2*nomtsys),allaxes=False) 1465 selection = selector() 1466 selection.set_polarisation(0) 1467 data.set_selection(selection) 1468 data.scale(xtsys/nomtsys) 1469 1470 selection.set_polarisation(1) 1471 data.set_selection(selection) 1472 data.scale(ytsys/nomtsys) 1473 1474 selection.set_polarisation(0) 1475 data.set_selection(selection) 1476 data.scale((xtsys+ytsys)/(2*nomtsys)) 1477 1478 selection.set_polarisation(0) 1479 data.set_selection(selection) 1480 data.scale((xtsys+ytsys)/(2*nomtsys)) 1413 1481 \end{verbatim} 1414 1482 … … 1436 1504 # transition 1437 1505 d1667 = d1665.copy() 1438 d1667.set_restfreqs( lines=['OH1667'])1439 d1667.summary 1506 d1667.set_restfreqs([1667.3590], 'MHz') 1507 d1667.summary() 1440 1508 1441 1509 # Copy out the scan we wish to process … … 1443 1511 g351_7 = d1667.get_scan('351p160') 1444 1512 1445 # Plot the data 1446 plotter.plot(g351_5,g351_7) # Only shows one panel 1513 # Baseline both 1514 msk = g351_5.create_mask([-30,-25],[-5,0]) 1515 g351_5.poly_baseline(msk,order=1) 1516 msk = g351_7.create_mask([-30,-25],[-5,0]) 1517 g351_7.poly_baseline(msk,order=1) 1518 1519 1520 # Plot the data. The plotter can only plot a single scantable 1521 # So we must merge the two tables first 1522 1523 plotscans = merge(g351_5, g351_7) 1524 1525 plotter.plot(plotscans) # Only shows one panel 1447 1526 1448 1527 # Tell the plotter to stack polarisation and panel scans … … 1457 1536 plotter.set_range(-30,10) 1458 1537 1459 # Baseline the data1460 msk = g351_5.create_mask([-20,-15],[0,5])1461 g351_5.poly_baseline(msk,1)1462 msk = g351_7.create_mask([-20,-15],[0,5])1463 g351_7.poly_baseline(msk,1)1464 1465 1538 # Update the plot with the baselined data 1466 1539 plotter.plot() 1467 1540 1468 1541 # Look at the various polarisation products 1469 plotter.set_cursor(pol='RR LL') 1470 plotter.set_cursor(pol='I Plinear') 1471 plotter.set_cursor(pol='I Q U V') 1542 selection = selector() 1543 selection.set_polarisations(``RR LL'') 1544 plotter.set_selection(selection) 1545 selection.set_polarisations(``I Plinear'') 1546 plotter.set_selection(selection) 1547 selection.set_polarisations(``I Q U V'') 1548 plotter.set_selection(selection) 1472 1549 1473 1550 # Save the plot as postscript 1474 plotter.save('g3 61_stokes.ps')1551 plotter.save('g351_stokes.ps') 1475 1552 1476 1553 # Save the process spectra 1477 g351_5.save('junk5.asap') 1478 g351_7.save('junk7.asap') 1554 plotscans.save('g351.asap') 1479 1555 1480 1556 \end{verbatim} … … 1502 1578 print q 1503 1579 1580 del d 1581 1504 1582 # Plot/select in velocity 1505 1583 q.set_freqframe('LSRK') 1506 1584 q.set_unit('km/s') 1507 1585 1586 # Correct for gain/el effects 1587 1588 q.recalc_azel() # Tid does not write the elevation 1589 q.gain_el() 1590 q.opacity(0.05) 1591 1508 1592 # Seperate data from the (1,1)&(2,2) and (4,4) transitions 1509 1593 g1 = q.get_scan(range(6)) # Rows 0..5 … … 1511 1595 1512 1596 # Align data in velocity 1513 g1.freq_align( perif=True)1514 g2.freq_align( perif=True)1597 g1.freq_align() 1598 g2.freq_align() 1515 1599 1516 1600 # Average individual scans … … 1519 1603 1520 1604 # Rpfits file only contrains a single rest frequency. Set both 1521 a1.set_restfreqs( freqs=[23694.4700e6,23722.6336e6])1522 1523 plotter.plot(a1 ,a2)1605 a1.set_restfreqs([23694.4700e6,23722.6336e6]) 1606 1607 plotter.plot(a1) 1524 1608 plotter.set_mode('i','s') 1525 1609 1526 1610 a1.auto_poly_baseline() 1527 a2.auto_poly_baseline()1528 1611 1529 1612 plotter.plot() 1530 1613 1531 1614 a1.smooth('gauss',5) 1532 a2.smooth('gauss',5)1533 1615 plotter.plot() 1616 1534 1617 1535 1618 \end{verbatim} … … 1727 1810 called} 1728 1811 1729 \asaprc{scantable.allaxes}{{\bf True}/False}{Apply action to all axes1730 not just the cursor location}1731 1732 1812 \asaprc{scantable.plotter}{{\bf True}/False}{Use internal plotter} 1733 1813
Note:
See TracChangeset
for help on using the changeset viewer.