pax_global_header00006660000000000000000000000064132031131510014500gustar00rootroot0000000000000052 comment=1512f11a18b70c61845b35d5a017004d1b20b1f5 python-casacore-2.2.1/000077500000000000000000000000001320311315100146015ustar00rootroot00000000000000python-casacore-2.2.1/.coveragerc000066400000000000000000000001341320311315100167200ustar00rootroot00000000000000[report] omit = */python?.?/* */site-packages/nose/* *__init__* */tests/* python-casacore-2.2.1/.dockerignore000066400000000000000000000000561320311315100172560ustar00rootroot00000000000000.git .venv*/ .virtualenv*/ build/ *.egg-info/ python-casacore-2.2.1/.gitignore000066400000000000000000000002351320311315100165710ustar00rootroot00000000000000.idea doc/.build/ build/ dist/ *.pyc .vagrant/ casacore/*/_*.so python_casacore.egg-info/ casacore.egg-info/ *~ .coverage .virtualenv/ .virtualenv3/ htmlcov python-casacore-2.2.1/.travis.yml000066400000000000000000000011561320311315100167150ustar00rootroot00000000000000language: generic sudo: required dist: trusty os: - linux - osx matrix: allow_failures: - os: osx before_install: - .travis/before_install.sh install: - .travis/install.sh script: - .travis/script.sh deploy: provider: pypi user: gijzelaerr password: secure: cdrrma3XaFjtv4lHvag6dfhSbKBF8iLmVgPQEjXP8qa+WxHnkHObkyraYAFGqThDY/0lBdrBm7Og6l1JfAcSA2BjdPQYxujP8KEoVicPwlgwEJ5LZo4HqympWVk33APvbcYNw7K/CwEXNJCCD1tDiO4pdwkPAWuKlnYUVfZq2yI= on: tags: true repo: casacore/python-casacore after_success: coveralls notifications: webhooks: urls: - https://webhooks.gitter.im/e/08a570c12a3afa37d8e2 python-casacore-2.2.1/.travis/000077500000000000000000000000001320311315100161675ustar00rootroot00000000000000python-casacore-2.2.1/.travis/Dockerfile000066400000000000000000000010711320311315100201600ustar00rootroot00000000000000FROM kernsuite/base:3 RUN apt-get update && apt-get install -y casacore-data casacore-dev \ libboost-python-dev libcasa-python3-2 libcfitsio3-dev python-dev \ python-numpy python-setuptools python-six python3-all python3-dev \ python3-numpy python3-setuptools python3-six wcslib-dev python-pip \ python3-pip python-nose python3-nose ADD . /code WORKDIR /code RUN pip install -e . RUN pip3 install -e . RUN pip install -r tests/requirements.txt RUN pip3 install -r tests/requirements.txt RUN nosetests --with-coverage RUN nosetests3 --with-coverage python-casacore-2.2.1/.travis/before_install.sh000077500000000000000000000015131320311315100215160ustar00rootroot00000000000000#!/usr/bin/env bash set -e set -v if [ "$TRAVIS_OS_NAME" = linux ]; then true fi if [ "$TRAVIS_OS_NAME" = osx ]; then # isntall and configure miniconda wget https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh -O miniconda.sh; bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" hash -r conda config --set always_yes yes --set changeps1 no conda update -q conda conda config --add channels conda-forge # Useful for debugging any issues with conda conda info -a conda create -q -n testenv python=2.7 casacore=2.3.0 source activate testenv # setup casacore data mkdir $HOME/data cd $HOME/data wget ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar && tar xf WSRT_Measures.ztar && cd $HOME echo "measures.directory: $HOME/data" > $HOME/.casarc fi python-casacore-2.2.1/.travis/install.sh000077500000000000000000000005261320311315100201770ustar00rootroot00000000000000#!/usr/bin/env bash set -e set -v if [ "$TRAVIS_OS_NAME" = linux ]; then true fi if [ "$TRAVIS_OS_NAME" = osx ]; then cd $TRAVIS_BUILD_DIR python setup.py build_ext \ -L$HOME/miniconda/envs/testenv/lib \ -I$HOME/miniconda/envs/testenv/include pip install -e . pip install -r tests/requirements.txt fi python-casacore-2.2.1/.travis/script.sh000077500000000000000000000005711320311315100200350ustar00rootroot00000000000000#!/usr/bin/env bash set -e set -v if [ "$TRAVIS_OS_NAME" = linux ]; then cd $TRAVIS_BUILD_DIR docker build -f .travis/Dockerfile . fi if [ "$TRAVIS_OS_NAME" = osx ]; then export DYLD_LIBRARY_PATH=$HOME/miniconda/envs/testenv/lib export LD_LIBRARY_PATH=$HOME/miniconda/envs/testenv/lib nosetests --with-coverage travis-sphinx --nowarn -s doc build fi python-casacore-2.2.1/CHANGELOG.md000066400000000000000000000015031320311315100164110ustar00rootroot00000000000000# 2.2.0 - Expose MeasurementSet functionality (#61) - Many improvements to documentation and test coverage Thanks to Shibasis Patel (@shibasisp) our Google summer of Code '17 student. A full list of changes can be found on the issue tracker: https://github.com/casacore/python-casacore/milestone/6?closed=1 # 2.1.0 - Replaced references to pyrap -> casacore (issue #16) - Experimental support for Python3 (needs python3 branch build of casacore) - Link against correct Python on OSX when using homebrew (issue #15) # 2.0.0 - Renamed project from pyrap to python-casacore - Renamed modules from pyrap to casacore - Added backswards compatible module which imports casacore - Removed scons build dependency, just use setup.py - Depends on CASACORE 2.0 - Cleanup of project structure - Moved development to github python-casacore-2.2.1/LICENSE000066400000000000000000000431531320311315100156140ustar00rootroot00000000000000GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {description} Copyright (C) {year} {fullname} This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. {signature of Ty Coon}, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. python-casacore-2.2.1/MANIFEST.in000066400000000000000000000000671320311315100163420ustar00rootroot00000000000000include README.rst *.py recursive-include src *.cc *.h python-casacore-2.2.1/README.rst000066400000000000000000000050561320311315100162760ustar00rootroot00000000000000python-casacore =============== Python-casacore is a set of Python bindings for `casacore `_, a c++ library used in radio astronomy. Python-casacore replaces the old `pyrap `_. The python-casacore documentation can be found on `casacore.github.io/python-casacore `_. .. image:: https://travis-ci.org/casacore/python-casacore.svg?branch=master :target: https://travis-ci.org/casacore/python-casacore .. image:: https://coveralls.io/repos/github/casacore/python-casacore/badge.svg?branch=master :target: https://coveralls.io/github/casacore/python-casacore?branch=master Installation ============ Ubuntu 16.04 ------------ The easiest way to start using python-casacore is to enable the `KERN suite `_ repository and install the binary package :: $ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:kernsuite/kern-3 $ sudo apt-get update $ sudo apt-get install python-casacore from source ----------- install these requirements: * `setuptools `_ * `Casacore `_ >= 2.3 * `Boost-python `_ * `numpy `_ * `cfitsio `_ On ubuntu you can install these with: * enable the `KERN suite `_ * install build dependencies:: $ apt-get install casacore-dev python-numpy \ python-setuptools libboost-python-dev libcfitsio3-dev wcslib-dev * compile and install:: $ python ./setup.py install * if you need to supply compile parameters, for example if you have your casacore library installed in a different location have a look at the `build_ext` help:: $ python ./setup.py build_ext -h For example, if `casacore` is installed in `/opt/local/`, you can specify the library path and include path with:: $ python ./setup.py build_ext -I/opt/local/include -L/opt/local/lib $ python ./setup.py install Using pip --------- python-casacore is also available trough pip. Note that you need to manually satisfy the requirements mentioned above:: $ pip install python-casacore Support ======= if you have any problems, suggestions or questions please open an issue on the python-casacore github issue tracker. Credits ======= * `Ger van Diepen `_ * `Malte Marquarding `_ * `Gijs Molenaar `_ python-casacore-2.2.1/Vagrantfile000066400000000000000000000005511320311315100167670ustar00rootroot00000000000000# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.provision :shell, :path => "vagrant/provision.sh" # default vagrant config is not really enough config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end end python-casacore-2.2.1/casacore/000077500000000000000000000000001320311315100163615ustar00rootroot00000000000000python-casacore-2.2.1/casacore/__init__.py000066400000000000000000000000671320311315100204750ustar00rootroot00000000000000__version__ = "2.2.1" __mincasacoreversion__ = "2.3.0" python-casacore-2.2.1/casacore/fitting/000077500000000000000000000000001320311315100200255ustar00rootroot00000000000000python-casacore-2.2.1/casacore/fitting/__init__.py000077500000000000000000000344531320311315100221520ustar00rootroot00000000000000# __init__.py: Top level .py file for python ftting interface # Copyright (C) 2006,2007 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: __init__.py,v 1.1 2006/10/20 06:30:03 mmarquar Exp $ """Python interface to the Casacore scimath fitting module. Introduction ============ The fitting module provides least squares fitting. It can handle linear and non-linear; real and complex (including cases where unknowns are each other's conjugate); complete and singular-value-decomposition; with or without external constraints; general or specific cases. ------------------ The fitting module ------------------ For most uses we will create a single fitting object to work with:: from casacore.fitting import fitserver dfit = fitserver() More fitting tools can be created by either the fitter constructor (which creates and returns a separate fitting tool), or by the fitter method of an existing fitting tool, which returns a fit identifier, which can be used to indicate a specific sub-fitter in the fitter used by including a parameter 'id=' in all calls to the fitting tool's functions. The latter is especially useful in the case where many simultaneous solutions are necessary: it is more resource efficient, and also allows you to have an array of fit indices to loop over. In both cases the parameters of the tool can be given in the constructor (fitter method), or in a separate init method (see next example of the highest level use):: from casacore.fitting import fitserver myfit = fitserver() # general fitting object created # (needs initializing before it can be used) cpid = myfit.fitter(ftype='complex') # and another (sub-)fitter # with an id The theory behind the fitting module's operation is described in detail in (`Note 224 <../../casacore/doc/notes/224.html>`_). Fitting requires a model describing the data obtained. The model is a described as a functional with parameters to be solved for. Functionals can be pre-programmed functionals like poly, gauss1d, or free form like compiled. In the latter case an expression string describes the model. The model can depend on zero, one or more arguments, called x. The number of arguments determines the dimension of the model. Fitting also needs a set of data, called y. If the model is not 0-dimensional, each value x will have an observed value. E.g. for each hour of the day x you can have a measured temperature. Or in the case of multi-dimensions e.g. each pair of hour of the day at each height above the surface (x0, x1) you should have a y value. -------- Examples -------- Simple linear example --------------------- The example uses a set of x coordinates:: from numpy import arange x = -1 + 0.1*arange(21) The 'observed' values used are a simple 1-dim polynomial of order 2: 1 + 2(x+1) + 0.03(x+1)^2 == 3.03 +2.06x + 0.03x^2 We fill these values using the polynomial functional:: y = functionals.poly(2, [3.03, 2.06, 0.03])(x) To take the average of these points, we can do:: dfit.linear(functionals.compiled('p'), [], y) Note that an expression uses p (which is p0), p1 and x, x0, x1. Note also that since no argument is used in the expression, no x-values have to be given. We can get solutions and errors from these data (see for details the separate routine descriptions):: >>> dfit.solution() 3.041 # Compare with the result: >>> print sum(y)/len(y) 3.041 >>> print dfit.sd() # standard deviation per observation 1.27824 >>> print dfit.stddev() # standard deviation per weight 1.27824 >>> print dfit.error() # errors in solved parameters array( [0.278934]) >>> print dfit.rank() # rank of solution 1 >>> print dfit.covariance() # covariance matrix [[0.047619]] We can also try to use a 0-order polynomial. Note that a polynomial, even a zero-order one, is a 1-dim function, and we need an x defined:: >>> dfit.linear(dfs.poly(0), [], y) RuntimeError: Linear fitter x and y lengths disagree >>> dfit.linear(dfs.poly(0),x,y) print >>> dfit.solution() 3.041 We would like to check the results, so we will do an average in a separate fitter:: >>> id = dfit.fitter() # get a new fitter >>> dfit.linear(dfs.compiled('p'), [], y, fid=id) # get average >>> dfit.solution() - dfit.solution(fid=id) # check difference -4.44089e-16 # to really show we recalculate and check separately: >>> dfit.linear(dfs.compiled('p'), [], array(y)/2, fid=id) # calculate new average >>> print dfit.solution() - dfit.solution(fid=id) [1 .5205] A 1-order polynomial is now easy:: >>> dfit.linear(dfs.poly(1), x, y) >>> print dfit.solution() [3.041, 2.06] >>> print dfit.chi2() 0.00201894 >>> print dfit.error() [0.00224944, 0.00371484] >>> print dfit.sd() 0.0103082 Note that each 'equation' can also be given a weight or standard deviation. 2-dimensional example --------------------- A 2-dim model is done the same way. The x vector has now n pairs of values. The Glish rbind can help in creating these pairs:: >>> x1 = arange(1, 6) >>> x2 = 0.1*x1 >>> x1 = ravel(array([x1,x2]).transpose()) # combine into pairs. Check: >>> print x1 array([ 1. , 0.1, 2. , 0.2, 3. , 0.3, 4. , 0.4, 5. , 0.5]) >>> dfit.linear(dfs.compiled('p*x + p1*sin(x1)'), x1, dfs.compiled('3*x+7*sin(x[2])').f(x1)) >>> print dfit.solution() [ 3. 7.] Non-linear simple example ------------------------- If the model is non-linear in the parameters to be solved, the functional method should be used. The main difference is that a guess solution must be inserted in the model parameters. In the following that is not necessary, since the default zero values suffice if the function is linear:: >>> dfit.functional(dfs.compiled('p*x + p1*sin(x1)'), x1, dfs.compiled('3*x+7*sin(x[2])').f(x1), id=id) >>> dfit.solution(fid=id) [ 3. 7.] >>> dfit.solution(fid=id)-dfit.solution() [ 6.17284002e-13 -6.35846931e-12] # Try with an intial guess >>> dfit.functional(dfs.compiled('p*x + p1*sin(x1)', [3,7]), x1, dfs.compiled('3*x+7*sin(x[2])').f(x1), fid=id2) >>> dfit.solution(fid=id2) [ 3. 7.] >>> dfit.solution(fid=id2)-dfit.solution() [ 6.17284002e-13 -6.35846931e-12] Functional variety ------------------ Just to show the model can be anything, we redo the fit of an order 1 polynomial to the x, y data:: >>> dfit.linear(dfs.poly(1), x,y) >>> dfit.solution() [ 3.041 2.06] Now try the same by a sum of odd and even polynomials of default order (note the order):: a = dfs.compound() a.add(dfs.functional('oddp')) a.add(dfs.functional('evenp')) dfit.linear(a,x,y,id=id2) dfit.solution(id=id2) [ 2.06 3.041] And the combination of an odd (2x) and an even polynomial (3):: a = dfs.combi() a.add(dfs.functional('oddp', params=2)) a.add(dfs.functional('evenp', params=3)) dfit.linear(a, x, y) >>> dfit.solution() [ 1.03 1.01367] Use constraints --------------- We have measured a number of anlgles around a triangle. Each angle is measured 10 times (nominally 50, 60, 70 deg). Solving the angles will give:: >>> import numpy >>> yz = numpy.array([numpy.zeros(10) + 50 + numpy.random.normal(0,1,10), numpy.zeros(10) + 60 + numpy.random.normal(0,1,10), numpy.zeros(10) + 70 + numpy.random.normal(0,1,10)]).flatten() # Create 3*10 equations >>> xz = array([1,0,0]*10 + [0,1,0]*10 + [0,0,1]*10) # The equation used and solve >>> f = dfs.compiled('p*x+p1*x1+p2*x2') >>> dfit.linear(f, xz, yz) >>> print dfit.solution(), 'sum=', sum(dfit.solution()) [49.7079 60.2427 70.092] sum= 180.043 >>> dfit.error() [ 0.334828 0.334828 0.334828] # Add a constraint: sum of angles 180deg >>> dfit.addconstraint(x=[1,1,1],y=180) >>> dfit.linear(f,xz,yz) >>> print dfit.solution(), 'sum=', sum(dfit.solution()) [ 49.6937 60.2285 70.0778] sum= 180 >>> print dfit.error() [ 0.273413 0.273413 0.273413] # Add another constraint, since we know second angle 60deg >>> dfit.addconstraint(x=[0,1,0], y=60) >>> dfit.linear(f,xz,yz) >>> print dfit.solution(), 'sum=', sum(dfit.solution()) [ 49.8079 60 70.1921] sum= 180 >>> print dfit.error() [0.239827 0 0.239827] Non-linear equation and constraints ----------------------------------- In the following we have 2 Gaussian profiles and an offset. We add some noise, and solve assuming we have a fair estimate of the position of the Gaussians. Note that if the first estimate is beyond the real half-value point, the fitting will be difficult, due to the derivatives changing sign:: # The profile to generate and the parameters to use # (in essence 10 + 20 * exp (-((x-10)/4)^2) + 10 * exp(-((x-33)/4)^2) ) f = dfs.compiled('p6+p0*exp(-((x-p1)/p2)^2) + p3*exp(-((x-p4)/p5)^2)', [20, 10, 4, 10, 33, 4, 10]) xg = 0.5 * numpy.arange(1, 101) - 0.5 yg = numpy.array(f(xg)) + numpy.random.normal(0,0.3,100) # Make an intial guess f.set_parameters([22, 11, 5, 10, 30, 5, 9]) # Solve dfit.clearconstraints() dfit.functional(f,xg,yg) print dfit.solution() print dfit.solution() - numpy.array([20., 10, 4, 10, 33, 4, 10]) print dfit.error() [0.211312 0.0334257 0.0527771 0.213666 0.0652003 0.102782 0.082641] # We know that the two lines have a peak ratio of 2: Amp1-2Amp2 = 0 dfit.addconstraint([1, 0, 0, -2, 0, 0, 0]) dfit.functional(f, xg, yg) print dfit.solution() print dfit.solution() - numpy.array([20., 10, 4, 10, 33, 4, 10]) print dfit.solution()[0]/dfit.solution()[3] print dfit.error() # We know that the lines originated in same place: width1 == width2 # Note that the default assumed value is 0.0 dfit.addconstraint([0, 0, 1, 0, 0, -1, 0]) dfit.functional(f, xg, yg) print dfit.solution() dfit.solution() - numpy.array([20, 10, 4, 10, 33, 4, 10]) dfit.solution()[2]-dfit.solution()[5] dfit.error() # And see what happens if we assume that the widths are 4 dfit.addconstraint([0, 0, 1, 0, 0, 0, 0], 4) dfit.functional(f, xg, yg) dfit.solution() dfit.solution() - [20, 10, 4, 10, 33, 4, 10] dfit.error() Deficient solutions and SVD constraints --------------------------------------- *DOES NOT WORK* In some cases solutions of the least-squares equations is not completely possible. An example is e.g. the solution of the closures equations in synthesis calibrations, where a missing phase zero and slope and a missing absolute gain cannot be solved for. The fitting described here will always provide a solution, even in the case of a set of incomplete equations. After the solution the deficiency can be checked. If there is a rank deficiency, the set of 'constraints' that makes a solution possible (in a way similar to SVD, i.e. providing a missing set of orthogonal equations) is available through the constr function:: # Provide a set of equations. x = array([1,1,1]*10) y = 180 + numpy.zeros(10) + numpy.random.normal(0, 3, 10) f = dfs.functional('hyper', 3) dfit.linear(f,x,y) dfit.deficiency() 2 dfit.solution() [60.0262 60.0262 60.0262] dfit.constraint() [-1 0 1 -1 1 0] # The SVD constraints can be used as constraints in subsequent solutions: dfit.addconstraint(x=dfit.constraint(1)) T dfit.addconstraint(x=dfit.constraint(2)) T dfit.linear(f,xz,yz) T dfit.solution() [60.0262 60.0262 60.0262] dfit.rank() 3 dfit.deficiency() 0 dfit.error() [0.202801 0.202801 0.202801] Complex fitting --------------- The fitter can handle functions of complex variables. In the following example a second order polynomial is first fitted real with a first order linear polynomial. The same is repeated complex (with real data); and then a complex value is fitted. An example of a 2-dimensional non-linear function is also given:: # Define x and y data >>> x = -1 + numpy.arange(0,21)*0.1 >>> y = dfs.poly(2, [3.03, 2.06, 0.03])(x) # fit a first order polynomial >>> dfit.linear(dfs.poly(1), x,y) >>> print 'linear', dfit.solution() linear [ 3.041 2.06] # Get a complex fitter and see the same fit >>> id1 = dfit.fitter() >>> dfit.set(ftype='complex', fid=id1) >>> dfit.linear(dfs.poly(1, dtype='complex'), x, y, fid=id1) >>> dfit.solution(fid=id1) [ 3.041+0j 2.06+0j] # Make a complex yi and redo >>> yi = dfs.poly(2, [3.03, 2.06, 0.03])(x) >>> yi = yi - 3j*array(dfs.poly(2, [3.03+0j, 2.06, 0.03])(x)) >>> dfit.linear(dfs.poly(1, dtype='complex'), x, yi, fid=id1) >>> dfit.solution(fid=id1) [ 3.041-9.123j 2.06-6.18j] # A non-linear 2-dimensional function, real and complex >>> id2 = dfit.fitter() >>> dfit.functional(dfs.compiled('p*x + p1*sin(x1)', [3,7]), x1, dfs.compiled('3*x+7*sin(x[2])')(x1), fid=id2) >>> x1 = arange(1,6) >>> x2 = 0.1*x1 >>> x1 = array(zip(x1,x2)).flatten() >>> dfit.functional(dfs.compiled('p*x + p1*sin(x1)', [3,7]),x1, dfs.compiled('3*x+7*sin(x[2])').f(x1), fid=id2) >>> dfit.solution(fid=id2) >>> dfit.set(type=dfit.complex(), fid=id2) >>> dfit.functional(dfs.compiled('p*x + p1*sin(x1)', [3,7]),x1, dfs.compiled('3*x+7*sin(x[2])').f(x1), fid=id2) >>> dfit.solution(fid=id2) """ from .fitting import * python-casacore-2.2.1/casacore/fitting/fitting.py000066400000000000000000000426261320311315100220550ustar00rootroot00000000000000from ._fitting import fitting import numpy as NUM from casacore import six from casacore.functionals import * class fitserver(object): """Create a `fitserver instance. The object can be created without arguments (in which case it is assumed to be a real fitter), or with the arguments specifying the number of unknowns to be solved for (a number not relevant in practice); and the type of solution: real, complex, conjugate (complex with both the unknown and its conjugate in the condition equations), separable complex, asreal complex with the real and imaginary part seen as independent unknowns. All solutions need a model (specified as a :mod:`casacore.functionals`. All solutions are done using an SVD type method. A collinearity factor can be specified, which is in essence the sine squared of the minimum angle between two normal equation columns that are still to be considered independent. For automatic non-linear solutions, a Levenberg-Marquardt factor (see`Note 224 <../../casacore/doc/notes/224.html>`_) is used, which can be specified as well. In the case of non-linear solutions that have to be handled by the system, an initial estimate for the model parameters is necessary. :param n: number of unknowns :param ftype: type of solution Allowed: real, complex, separable, asreal, conjugate :param colfac: collinearity factor :param lmfac: Levenberg-Marquardt factor :param fid: the id of a sub-fitter """ def __init__(self, n=0, m=1, ftype=0, colfac=1.0e-8, lmfac=1.0e-3): self._fitids = [] self._typeids = {"real": 0, "complex": 1, "separable": 3, "asreal": 7, "conjugate": 11} self._fitproxy = fitting() fid = self.fitter(n=n, ftype=ftype, colfac=colfac, lmfac=lmfac) if fid != 0: raise RuntimeError("System problem creating fitter server") def fitter(self, n=0, ftype="real", colfac=1.0e-8, lmfac=1.0e-3): """Create a sub-fitter. The created sub-fitter can be used in the same way as a fitter default fitter. This function returns an identification, which has to be used in the `fid` argument of subsequent calls. The call can specify the standard constructor arguments (`n`, `type`, `colfac`, `lmfac`), or can specify them later in a :meth:`set` statement. :param n: number of unknowns :param ftype: type of solution Allowed: real, complex, separable, asreal, conjugate :param colfac: collinearity factor :param lmfac: Levenberg-Marquardt factor :param fid: the id of a sub-fitter """ fid = self._fitproxy.getid() ftype = self._gettype(ftype) n = len(self._fitids) if 0 <= fid < n: self._fitids[fid] = {} elif fid == n: self._fitids.append({}) else: # shouldn't happen raise RangeError("fit id out of range") self.init(n=n, ftype=ftype, colfac=colfac, lmfac=lmfac, fid=fid) return fid def init(self, n=0, ftype="real", colfac=1.0e-8, lmfac=1.0e-3, fid=0): """Set selected properties of the fitserver instance. Like in the constructor, the number of unknowns to be solved for; the number of simultaneous solutions; the ftype and the collinearity and Levenberg-Marquardt factor can be specified. Individual values can be overwritten with the :meth:`set` function. :param n: number of unknowns :param ftype: type of solution Allowed: real, complex, separable, asreal, conjugate :param colfac: collinearity factor :param lmfac: Levenberg-Marquardt factor :param fid: the id of a sub-fitter """ ftype = self._gettype(ftype) self._fitids[fid]["stat"] = False self._fitids[fid]["solved"] = False self._fitids[fid]["haserr"] = False self._fitids[fid]["fit"] = False self._fitids[fid]["looped"] = False if self._fitproxy.init(fid, n, ftype, colfac, lmfac): self._fitids[fid]["stat"] = self._getstate(fid) else: return False def _gettype(self, ftype): if isinstance(ftype, str): ftype = ftype.lower() if ftype not in self._typeids: raise TypeError("Illegal fitting type") else: return self._typeids[ftype] elif isinstance(ftype, int): if ftype not in self._typeids.values(): raise TypeError("Illegal fitting type") else: raise TypeError("Illegal fitting type") return ftype def _settype(self, ftype=0): for k, v in self._typeids.items(): if ftype == v: return k return "real" def _checkid(self, fid=0): if not (0 <= fid < len(self._fitids) and isinstance(self._fitids[fid], dict) and "stat" in self._fitids[fid] and isinstance(self._fitids[fid]["stat"], dict)): raise ValueError("fit id out of range") def _reshape(self, fid=0): pass def _getstate(self, fid): d = self._fitproxy.getstate(fid) if "typ" in d: d["typ"] = self._settype(d["typ"]) return d def set(self, n=None, ftype=None, colfac=None, lmfac=None, fid=0): """Set selected properties of the fitserver instance. All unset properties remain the same (in the :meth:`init` method all properties are (re-)initialized). Like in the constructor, the number of unknowns to be solved for; the number of simultaneous solutions; the ftype (as code); and the collinearity and Levenberg-Marquardt factor can be specified. :param n: number of unknowns :param ftype: type of solution Allowed: real, complex, separable, asreal, conjugate :param colfac: collinearity factor :param lmfac: Levenberg-Marquardt factor :param fid: the id of a sub-fitter """ self._checkid(fid) if ftype is None: ftype = -1 else: ftype = self._gettype(ftype) if n is None: n = -1 elif n < 0: raise ValueError("Illegal set argument n") if colfac is None: colfac = -1 elif colfac < 0: raise ValueError("Illegal set argument colfac") if lmfac is None: lmfac = -1 elif lmfac < 0: raise ValueError("Illegal set argument lmfac") self._fitids[fid]["stat"] = False self._fitids[fid]["solved"] = False self._fitids[fid]["haserr"] = False self._fitids[fid]["fit"] = True self._fitids[fid]["looped"] = False if n != -1 or ftype != -1 or colfac != -1 or lmfac != -1: if not self._fitproxy.set(fid, n, ftype, colfac, lmfac): return False self._fitids[fid]["stat"] = self._getstate(fid) return True def done(self, fid=0): """Terminates the fitserver.""" self._checkid(fid) self._fitids[fid] = {} self._fitproxy.done(fid) def reset(self, fid=0): """Reset the object's resources to its initialized state. :param fid: the id of a sub-fitter """ self._checkid(fid) self._fitids[fid]["solved"] = False self._fitids[fid]["haserr"] = False if not self._fitids[fid]["looped"]: return self._fitproxy.reset(fid) else: self._fitids[fid]["looped"] = False return True def getstate(self, fid=0): """Obtain the state of the fitter object or a sub-fitter. :param fid: the id of a sub-fitter """ self._checkid(fid) return self._fitids[fid]["stat"] def clearconstraints(self, fid=0): """Clear the constraints.""" self._checkid(fid) self._fitids[fid]["constraint"] = {} def addconstraint(self, x, y=0, fnct=None, fid=0): """Add constraint.""" self._checkid(fid) i = 0 if "constraint" in self._fitids[fid]: i = len(self._fitids[fid]["constraint"]) else: self._fitids[fid]["constraint"] = {} # dict key needs to be string i = str(i) self._fitids[fid]["constraint"][i] = {} if isinstance(fnct, functional): self._fitids[fid]["constraint"][i]["fnct"] = fnct.todict() else: self._fitids[fid]["constraint"][i]["fnct"] = \ functional("hyper", len(x)).todict() self._fitids[fid]["constraint"][i]["x"] = [float(v) for v in x] self._fitids[fid]["constraint"][i]["y"] = float(y) six.print_(self._fitids[fid]["constraint"]) def fitpoly(self, n, x, y, sd=None, wt=1.0, fid=0): if self.set(n=n + 1, fid=fid): return self.linear(poly(n), x, y, sd, wt, fid) def fitspoly(self, n, x, y, sd=None, wt=1.0, fid=0): """Create normal equations from the specified condition equations, and solve the resulting normal equations. It is in essence a combination. The method expects that the properties of the fitter to be used have been initialized or set (like the number of simultaneous solutions m the type; factors). The main reason is to limit the number of parameters on the one hand, and on the other hand not to depend on the actual array structure to get the variables and type. Before fitting the x-range is normalized to values less than 1 to cater for large difference in x raised to large powers. Later a shift to make x around zero will be added as well. :param n: the order of the polynomial to solve for :param x: the abscissa values :param y: the ordinate values :param sd: standard deviation of equations (one or more values used cyclically) :param wt: an optional alternate for `sd` :param fid: the id of the sub-fitter (numerical) Example:: fit = fitserver() x = N.arange(1,11) # we have values at 10 'x' values y = 2. + 0.5*x - 0.1*x**2 # which are 2 +0.5x -0.1x^2 fit.fitspoly(3, x, y) # fit a 3-degree polynomial print fit.solution(), fit.error() # show solution and their errors """ a = max(abs(max(x)), abs(min(x))) if a == 0: a = 1 a = 1.0 / a b = NUM.power(a, range(n + 1)) if self.set(n=n + 1, fid=fid): self.linear(poly(n), x * a, y, sd, wt, fid) self._fitids[fid]["sol"] *= b self._fitids[fid]["error"] *= b return self.linear(poly(n), x, y, sd, wt, fid) def fitavg(self, y, sd=None, wt=1.0, fid=0): if self.set(n=1, fid=fid): return self.linear(compiled("p"), [], y, sd, wt, fid) def _fit(self, **kw): fitfunc = kw.pop("fitfunc") sd = kw.pop("sd") fid = kw.pop("fid") kw["id"] = fid if not isinstance(kw["fnct"], functional): raise TypeError("No or illegal functional") if not self.set(n=kw["fnct"].npar(), fid=fid): raise ValueError("Illegal fit id") fnct = kw["fnct"] kw["fnct"] = fnct.todict() self.reset(fid) x = self._as_array(kw["x"]) if x.ndim > 1 and fnct.ndim() == x.ndim: x = x.flatten() y = self._as_array(kw["y"]) if y.ndim > 1 and fnct.ndim() == y.ndim: x = y.flatten() wt = self._as_array(kw["wt"]) if sd is not None: sd = self._as_array(sd) wt = sd.copy() wt[sd == 0] = 1 wt = 1 / abs(wt * NUM.conjugate(wt)) wt[NUM.logical_or(sd == -1, sd == 0)] = 0 ftype = fitfunc dtype = 'float' if ( self.getstate(fid)["typ"] != "real" or NUM.iscomplexobj(x) or NUM.iscomplexobj(y) or NUM.iscomplexobj(wt) ): ftype = "cx%s" % fitfunc dtype = 'complex' kw["x"] = self._as_array(x, dtype) kw["y"] = self._as_array(y, dtype) kw["wt"] = self._as_array(wt, dtype) if "constraint" not in self._fitids[fid]: self._fitids[fid]["constraint"] = {} kw["constraint"] = self._fitids[fid]["constraint"] func = getattr(self._fitproxy, ftype) result = func(**kw) self._fitids[fid].update(result) self._fitids[fid]["solved"] = True self._fitids[fid]["haserr"] = True self._fitids[fid]["looped"] = False def functional(self, fnct, x, y, sd=None, wt=1.0, mxit=50, fid=0): """Make a non-linear least squares solution. This will make a non-linear least squares solution for the points through the ordinates at the abscissa values, using the specified `fnct`. Details can be found in the :meth:`linear` description. :param fnct: the functional to fit :param x: the abscissa values :param y: the ordinate values :param sd: standard deviation of equations (one or more values used cyclically) :param wt: an optional alternate for `sd` :param mxit: the maximum number of iterations :param fid: the id of the sub-fitter (numerical) """ self._fit(fitfunc="functional", fnct=fnct, x=x, y=y, sd=sd, wt=wt, mxit=mxit, fid=fid) nonlinear = functional def linear(self, fnct, x, y, sd=None, wt=1.0, fid=0): """Make a linear least squares solution. Makes a linear least squares solution for the points through the ordinates at the x values, using the specified fnct. The x can be of any dimension, depending on the number of arguments needed in the functional evaluation. The values should be given in the order: x0[1], x0[2], ..., x1[1], ..., xn[m] if there are n observations, and m arguments. x should be a vector of m*n length; y (the observations) a vector of length n. :param fnct: the functional to fit :param x: the abscissa values :param y: the ordinate values :param sd: standard deviation of equations (one or more values used cyclically) :param wt: an optional alternate for `sd` :param fid: the id of the sub-fitter (numerical) """ self._fit(fitfunc="linear", fnct=fnct, x=x, y=y, sd=sd, wt=wt, fid=fid) def _getval(self, valname, fid): self._checkid(fid) if not self._fitids[fid]["solved"]: raise RuntimeError("Not solved yet") return self._fitids[fid][valname] def solution(self, fid=0): """Return the solution for the fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("sol", fid) def rank(self, fid=0): """Obtain the rank(in SVD sense) of a fit. The :meth:`constraint` method will show the equations that are orthogonal to the existing ones, and which will make the solution possible. :param fid: the id of the sub-fitter (numerical) """ return self._getval("rank", fid) def deficiency(self, fid=0): """Obtain the missing rank (in SVD sense) of a fit. The :meth:`constraint` method will show the equations that are orthogonal to the existing ones, and which will make the solution possible. :param fid: the id of the sub-fitter (numerical) """ return self._getval("deficiency", fid) def chi2(self, fid=0): """Obtain the chi squared of a fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("chi2", fid) def sd(self, fid=0): """Obtain the standard deviation per unit of weight of a fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("sd", fid) def mu(self, fid=0): """Obtain the standard deviation per condition equation of a fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("mu", fid) stddev = mu def covariance(self, fid=0): """Obtain the covariance matrix of a fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("covar", fid) def error(self, fid=0): """Obtain the errors in the unknowns of a fit. :param fid: the id of the sub-fitter (numerical) """ return self._getval("error", fid) def constraint(self, n=-1, fid=0): """Obtain the set of orthogonal equations that make the solution of the rank deficient normal equations possible. :param fid: the id of the sub-fitter (numerical) """ c = self._getval("constr", fid) if n < 0 or n > self.deficiency(fid): return c else: raise RuntimeError("Not yet implemented") def fitted(self, fid=0): """Test if enough Levenberg-Marquardt loops have been done. It returns True if no improvement possible. :param fid: the id of the sub-fitter (numerical) """ self._checkid(fid) return not (self._fitids[fid]["fit"] > 0 or self._fitids[fid]["fit"] < -0.001) def _as_array(self, v, dtype=None): if not hasattr(v, "__len__"): v = [v] return NUM.asarray(v, dtype) python-casacore-2.2.1/casacore/functionals/000077500000000000000000000000001320311315100207065ustar00rootroot00000000000000python-casacore-2.2.1/casacore/functionals/__init__.py000077500000000000000000000070231320311315100230240ustar00rootroot00000000000000# __init__.py: Top level .py file for python functionals interface # Copyright (C) 2006,2007 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: __init__.py,v 1.1 2006/09/29 06:42:55 mmarquar Exp $ """ Introduction ============ A functional is a function with parameters, defined as *f(p;x)*, where *p* are the parameters, and *x* the arguments. Methods are available to calculate the value of a function for a series of argument values for the given set of parameters, and for the automatic calculation of the derivatives with respect to the parameters. The created functionals can be used for fitiing as provided by :mod:`casacore.fitting`. A functional has a mask associated with it, to indicate if certain parameters have to be solved for. See masks for details. To access the functionals module ``import casacore.functionals``. Functionals are created in a variety of ways, in general by specifying the name of the functional, together with some necessary information like e.g. the order of a polynomial, or the code needed to compile your privately defined function. Parameters can be set at creation time or later:: >>> from casacore.functionals import functional, gaussian1d >>> a = gaussian1d() # creates a 1D Gaussian, default arguments >>> b = functional('gaussian1d') # creates the same one >>> print a.f(1) # the value at x=1 [0.062500000000000028] >>> print a(1) [0.062500000000000028] >>> print a.fdf([0,0.5]); # value and derivatives >>> print a([0, 0.5], derivatives=True) In some cases an order can be specified as well (e.g. for polynomials):: >>> from casacore.functionals import functional, poly >>> a = poly(3) # creates a 3rd order polynomial >>> print a {'ndim': 1, 'masks': array([ True, True, True, True], dtype=bool), 'params': array([ 1., 1., 1., 1.]), 'npar': 4, 'type': 5, 'order': 3} An extremely valuable aspect of the Functionals module is the ability to create a functional from a compiled string specifying an arbitrary function. For example, let us make our own polynomial ``1 + 2*x + 3*x2`` and evaluate it at a few abcissa locations:: >>> from casacore.functionals import compiled >>> a = compiled('p0 + p1*x + p2*x*x', [1,2,3]) # Define >>> a([0,10,20]) # Evaluate at x=[0,10,20] [1.0, 321.0, 1241.0] The functions created can also be used to specify the function to be fitted in a least squares fit. """ from .functional import * python-casacore-2.2.1/casacore/functionals/functional.py000066400000000000000000000416331320311315100234310ustar00rootroot00000000000000from ._functionals import _functional import numpy def copydoc(fromfunc, sep="\n"): """ Decorator: Copy the docstring of `fromfunc` """ def _decorator(func): sourcedoc = fromfunc.__doc__ if func.__doc__ is None: func.__doc__ = sourcedoc else: func.__doc__ = sep.join([sourcedoc, func.__doc__]) return func return _decorator class functional(_functional): def __init__(self, name=None, order=-1, params=None, mode=None, dtype=0): if isinstance(dtype, str): dtypes = {'real': 0, 'complex': 1} dtype = dtypes.get(dtype.lower()) if numpy.iscomplexobj(params): dtype = 1 self._dtype = dtype progtext = "" if not isinstance(name, str): raise TypeError("'name' was not of type string") if not (isinstance(order, int) or isinstance(order, str)): raise TypeError("'order' was not of type integer or string") else: if isinstance(order, str): progtext = order order = -1 # our own functionals server d = {'type': name, 'order': order, 'progtext': progtext} if isinstance(mode, dict): d['mode'] = mode _functional.__init__(self, d, self._dtype) if hasattr(params, "__len__"): params = self._flatten(params) if len(params) == 0: pass elif len(params) == self.npar(): self.set_parameters(params) else: raise ValueError("Incorrect number of parameters " "specified in functional") def __repr__(self): return str(self.todict()) def _flatten(self, x): if (isinstance(x, numpy.ndarray) and x.ndim > 1 and x.ndim == self.ndim()): return x.flatten() return x def ndim(self): return _functional.ndim(self) def npar(self): """ Return the number of parameters of the functional :retval: int """ return _functional.npar(self) def __len__(self): return self.npar() # def __getitem__(self, i): # return self.get_parameters()[i] # def __setitem__(self, i, v): # return self.set_parameter(i, v) def set_parameters(self, params): params = self._flatten(params) if self._dtype == 0: return _functional._setparameters(self, params) else: return _functional._setparametersc(self, params) def set_parameter(self, idx, val): if self._dtype == 0: return _functional._setpar(self, idx, val) else: return _functional._setparc(self, idx, val) def get_parameters(self): if self._dtype == 0: return _functional._parameters(self) else: return _functional._parametersc(self) def f(self, x): """Calculate the value of the functional for the specified arguments (taking any specified mask into account). :param x: the value(s) to evaluate at """ x = self._flatten(x) if self._dtype == 0: return numpy.array(_functional._f(self, x)) else: return numpy.array(_functional._fc(self, x)) def __call__(self, x, derivatives=False): if derivatives: return numpy.array(self.fdf(x)) else: return numpy.array(self.f(x)) def fdf(self, x): """Calculate the value of the functional for the specified arguments, and the derivatives with respect to the parameters (taking any specified mask into account). :param x: the value(s) to evaluate at """ x = self._flatten(x) n = 1 if hasattr(x, "__len__"): n = len(x) if self._dtype == 0: retval = _functional._fdf(self, x) else: retval = _functional._fdfc(self, x) if len(retval) == n: return numpy.array(retval) return numpy.array(retval).reshape(self.npar() + 1, n // self.ndim()).transpose() def add(self, other): if not isinstance(other, functional): raise TypeError("'other' is not a functional") if self._dtype != other._dtype: raise TypeError("'other' is not of the same value type") if self._dtype == 0: _functional._add(self, other) else: _functional._addc(self, other) def set_mask(self, i, msk): _functional._setmask(self, i, msk) def set_masks(self, msk): _functional._setmasks(self, msk) def get_masks(self): return _functional._masks(self) def todict(self): return _functional.todict(self) class gaussian1d(functional): """Create a 1-dimensional Gaussian with the specified height, width and center. :param params: the [height, center, width] as a list """ def __init__(self, params=None, dtype=0): functional.__init__(self, name="gaussian1d", params=params, dtype=dtype) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> g = gaussian1d([1, 2, 3]) >>> print g.npar() 3 >>> print len(g) 3 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> a = gaussian1d() >>> print(a.f(0.0)) [ 1.] >>> print(a(0.0)) #equivalent [ 1.] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> g = gaussian1d() >>> print(g.fdf(0.0)) [[ 1., 1., 0., 0.]] >>> print(g(0.0, derivatives=True)) #equivalent [[ 1., 1., 0., 0.]] """ return functional.fdf(self, x) class gaussian2d(functional): """ Create a two-dimensional gaussian. :param params: list [amplitude, centers, major width, ratio, angle] of Gaussian default is [1, 0, 0, 1, 1, 0] :param dtype: The data type. One of 'real' or 0, or 'complex' or 1 """ def __init__(self, params=None, dtype=0): if params is None: params = [1, 0, 0, 1, 1, 0] functional.__init__(self, name="gaussian2d", params=params, dtype=dtype) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> g = gaussian2d([1, 2, 3][4, 5, 6]) >>> print g.npar() 6 >>> print len(g) 6 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> a = gaussian2d() >>> print(a.f(0.0)) [] >>> print(a(0.0)) #equivalent [] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> a = gaussian2d() >>> print(a.fdf(0)) [] >>> print(g(0.0, derivatives=True)) #equivalent [] """ return functional.fdf(self, x) class poly(functional): """ Create a polynomial of specified degree. The default parameters are all 1. (Note that using the generic functional function the parameters are all set to 0). :param order: the order of the polynomial (number of parameters -1) :param params: the values of the parameters as a list. :param dtype: the optional data type. Default is float, but will be auto-detected from `params`. Can be set to 'complex'. """ def __init__(self, order, params=None, dtype=0): functional.__init__(self, name="poly", order=order, params=params, dtype=dtype) if params is None: self.set_parameters([v + 1. for v in self.get_parameters()]) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> p = poly(5) >>> print p.npar() 6 >>> print len(p) 6 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> p = poly(5) >>> print(p.f(0.0)) [ 1.] >>> print(p(0.0)) # equivalent [ 1.] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> p = poly(5) >>> print(p.fdf(0.0)) [[ 1., 1., 0., 0., 0., 0., 0.]] >>>print(p(0.0, derivatives=True)) # equivalent [[ 1., 1., 0., 0., 0., 0., 0.]] """ return functional.fdf(self, x) class oddpoly(functional): """Create an odd polynomial of specified degree. :param order: the order of the polynomial :param params: the values of the parameters as a list. :param dtype: the optional data type. Default is float, but will be auto-detected from `params`. Can be set to 'complex'. """ def __init__(self, order, params=None, dtype=0): functional.__init__(self, name="oddpoly", order=order, params=params, dtype=dtype) if params is None: self.set_parameters([v + 1. for v in self.get_parameters()]) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> p = oddpoly(3) >>> print p.npar() 2 >>> print len(p) 2 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> p = oddpoly(3) >>> print(p.f(0.0)) [ 0.] >>> print(p(0.0)) # equivalent [ 0.] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> p = oddpoly(3) >>> print(p.fdf(0.0)) [[ 0., 0., 0.]] >>> print(p(0.0, derivatives=True)) # equivalent [[ 0., 0., 0.]] """ return functional.fdf(self, x) class evenpoly(functional): """Create an even polynomial of specified degree. :param order: the order of the polynomial :param params: the values of the parameters as a list. :param dtype: the optional data type. Default is float, but will be auto-detected from `params`. Can be set to 'complex'. """ def __init__(self, order, params=None, dtype=0): functional.__init__(self, name="evenpoly", order=order, params=params, dtype=dtype) if params is None: self.set_parameters([v + 1. for v in self.get_parameters()]) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> p = evenpoly(2) >>> print p.npar() 2 >>> print len(p) 2 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> p = evenpoly(2) >>> print(p.f(0.0)) [ 1.] >>> print(p(0.0)) # equivalent [ 1.] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> p = oddpoly(3) >>> print(p.fdf(0.0)) [[ 1., 1., 0.]] >>>print(p(0.0, derivatives=True)) # equivalent [[ 1., 1., 0.]] """ return functional.fdf(self, x) class chebyshev(functional): def __init__(self, order, params=None, xmin=-1., xmax=1., ooimode='constant', dtype=0): modes = "constant zeroth extrapolate cyclic edge".split() if ooimode not in modes: raise ValueError("Unrecognized ooimode") mode = {'interval': [float(xmin), float(xmax)], 'intervalMode': ooimode, 'default': float(0.0)} functional.__init__(self, name="chebyshev", order=order, params=params, mode=mode, dtype=dtype) if params is None: self.set_parameters([v + 1. for v in self.get_parameters()]) @copydoc(functional.npar) def npar(self): """ Equivalent:: >>> ch = chebyshev(2) >>> print ch.npar() 4 >>> print len(p) 4 """ return functional.npar(self) @copydoc(functional.f) def f(self, x): """ Example:: >>> ch = chebyshev(2) >>> print(ch.f(0.0)) [ 0.] >>> print(ch(0.0)) # equivalent [ 0.] """ return functional.f(self, x) @copydoc(functional.fdf) def fdf(self, x): """ Example:: >>> ch = chebyshev(2) >>> print(ch.fdf(0.0)) [[ 0., 1., 0., -1.]] >>>print(ch(0.0, derivatives=True)) # equivalent [[ 0., 1., 0., -1.]] """ return functional.fdf(self, x) class compound(functional): def __init__(self, dtype=0): """Create a compound function. This class takes a arbitary number of functions and generates a new single function object. Example:: >>> d = poly(2) >>> gauss1d = gaussian1d([1, 0, 1]) >>> sum = compound() >>> sum.add(d) >>> sum.add(gauss1d) >>> print(sum(2)) [ 7.00001526] """ functional.__init__(self, name="compound", dtype=dtype) class combi(functional): def __init__(self, dtype=0): """Form a linear combinations of functions object. Example:: >>> const = poly(0) >>> linear = poly(1) >>> square = poly(2) >>> c = combi() >>> c.add(const) >>> c.add(linear) >>> c.add(square) >>> print(c(0)) [ 3.] """ functional.__init__(self, name="combi", dtype=dtype) class compiled(functional): """Create a function based on the programable string. The string should be a single expression, which can use the standard operators and functions and parentheses, having a single value as a result. The parameters of the function can be addressed with the *p* variable. This variable can be indexed in two ways. The first way is using the standard algebraic way, where the parameters are: ``p (or p0), p1, p2, ...`` . The second way is by indexing, where the parameters are addressed as: p[0], p[1], ... . The arguments are accessed in the same way, but using the variable name x. The compilation determines the number of dimensions and parameters of the produced function. Operators are the standard operators (including comparisons, which produce a zero or one result; and conditional expression). In addition to the standard expected functions, there is an atan with either one or two arguments (although atan2 exists as well), and pi and ee with no or one argument. The functional created behaves as all other functionals, and hence can be used in combinations. Examples:: >>> from casacore.functionals import compiled >>> import math >>> a = compiled('sin(pi(0.5) ) +pi'); # an example >>> print a(0) array([ 4.1415926535897931]) >>> b = compiled('p*exp(-(x/p[2])^2)') >>> print b.get_parameters() [0.0, 0.0] >>> b.set_parameters([10, 1]) # change to height 10 and halfwidth 1 >>> print b([-1,-0.5,0,.5,1]) array([ 3.6787944117144233, 7.788007830714049, 10.0, 7.788007830714049, 3.6787944117144233]) # the next one is sync(x), catering for x=0 # using the fact that comparisons deliver values. Note # the extensive calculation to make sure no divison by 0 >>> synca = compiled('( (x==0) * 1)+( (x!=0) * sin(x+(x==0)*1)/(x+(x==0)*1) )') >>> print synca([-1,0,1]) [0.841471, 1., 0.841471] >>> print math.sin(1)/1 0.841471 # using conditional expressions: print compiled('x==0 ? 1 : sin(x)/x')([-1,0,1]) [0.841471, 1.0, 0.841471] """ def __init__(self, code="", params=None, dtype=0): functional.__init__(self, name="compiled", order=code, params=params, dtype=dtype) python-casacore-2.2.1/casacore/images/000077500000000000000000000000001320311315100176265ustar00rootroot00000000000000python-casacore-2.2.1/casacore/images/__init__.py000066400000000000000000000043771320311315100217520ustar00rootroot00000000000000# __init__.py: Python image functions # Copyright (C) 2008 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id$ """Python interface to the Casacore images module. A `casacore image <../../casacore/doc/html/group__Images__module.html>`_ represents an astronomical image of arbitrary dimensionality. Several image formats are recognized: `casacore paged image <../../casacore/doc/html/classcasa_1_1PagedImage.html>`_ is the native casacore image format stored in a casacore table. `HDF5 `_ is the HDF5 format often used in the earth science community. `FITS `_ is the well-known astronomical FITS format `miriad `_ is the format used by the radio-astronomical MIRIAD package. The following functionality exists: - get and put data (slices) - get or put a mask - get meta data like coordinates and history - get, put, or search optional image attributes (as used for LOFAR) - get statistics - form a subimage - form an image expression which is treated as an ordinary image - regrid the image - write the image to a FITS file """ # Make image interface available. from .image import image python-casacore-2.2.1/casacore/images/coordinates.py000066400000000000000000000263711320311315100225230ustar00rootroot00000000000000# coordinates.py: Python coordinate system wrapper # Copyright (C) 2008 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id$ from casacore import six class coordinatesystem(object): """ A thin wrapper for casacore coordinate systems. It dissects the coordinatesystem record returned from casacore images. This only handles one instance of each coordinate type. The possible types are ''direction'', ''spectral'', ''stokes'', ''linear'' and ''tabular''. The first, second, trird and fourth axis are respectively, 'Right Ascension','Declination','Stokes' and 'Frequency'. To make a coordinate object, these things should be taken care of.Like to make a spectral coordinate, a 4D image should be used as the 4th axis is 'Frequency' and so on. It uses reference semantics for the individual coordinates, e.g. the following will work:: cs = im.coordinates() cs["direction"].set_referencepixel([0.0,0.0]) # or equivalent cs.get_coordinates("direction").set_referencepixel([0.0,0.0]) """ def __init__(self, rec): self._csys = rec self._names = [] self._get_coordinatenames() def __str__(self): out = "" for coord in self: out += str(coord) return out def dict(self): return self._csys def summary(self): six.print_(str(self)) def _get_coordinatenames(self): """Create ordered list of coordinate names """ validnames = ("direction", "spectral", "linear", "stokes", "tabular") self._names = [""] * len(validnames) n = 0 for key in self._csys.keys(): for name in validnames: if key.startswith(name): idx = int(key[len(name):]) self._names[idx] = name n += 1 # reverse as we are c order in python self._names = self._names[:n][::-1] if len(self._names) == 0: raise LookupError("Coordinate record doesn't contain valid coordinates") def get_names(self): """Get the coordinate names """ return self._names def __getitem__(self, name): # reverse index back to fortran order as the record is using this i = self._names[::-1].index(name) return eval("%scoordinate(self._csys['%s'])" % (name, name + str(i))) # alias get_coordinate = __getitem__ def __setitem__(self, name, val): # reverse index back to fortran order as the record is using this i = self._names[::-1].index(name) assert isinstance(val, eval("%scoordinate" % name)) self._csys[name + str(i)] = val._coord # alias set_coordinate = __setitem__ def __iter__(self): for name in self._names: yield self.get_coordinate(name) def get_obsdate(self): return self._csys.get("obsdate", None) def get_observer(self): return self._csys.get("observer", None) def get_telescope(self): return self._csys.get("telescope", None) def get_referencepixel(self): return [coord.get_referencepixel() for coord in self] def set_referencepixel(self, values): for i, coord in enumerate(self): coord.set_referencepixel(values[i]) def get_referencevalue(self): return [coord.get_referencevalue() for coord in self] def set_referencevalue(self, values): for i, coord in enumerate(self): coord.set_referencevalue(values[i]) def get_increment(self): return [coord.get_increment() for coord in self] def set_increment(self, values): for i, coord in enumerate(self): coord.set_increment(values[i]) def get_unit(self): return [coord.get_unit() for coord in self] def get_axes(self): return [coord.get_axes() for coord in self] class coordinate(object): """Overwrite as neccessary """ def __init__(self, rec): self._coord = rec self._template = " %-16s: %s\n" def __str__(self): lname = self.__class__.__name__.capitalize() out = "%s Coordinate:\n" % lname[:-10] out += self._template % ("Reference Pixel", str(self.get_referencepixel())) out += self._template % ("Reference Value", str(self.get_referencevalue()) \ + " " + str(self.get_unit())) out += self._template % ("Increment", str(self.get_increment()) \ + " " + str(self.get_unit())) return out def dict(self): """Get the coordinate info as a dict""" return self._coord def get_axis_size(self, axis=0): """Get the length of the given axis in this coordinate -1 is returned if unknown. """ try: return self._coord["_axes_sizes"][axis] except: return -1 def get_image_axis(self, axis=0): """Get the image axis number of the given axis in this coordinate -1 is returned if unknown. """ try: return self._coord["_image_axes"][axis] except: return -1 # ALL list/array values have to be reversed as the coordsys dict holds # everything in fortran order. def get_referencepixel(self): """Get the reference pixel of the given axis in this coordinate.""" return self._coord.get("crpix", [])[::-1] def set_referencepixel(self, pix): """Set the reference pixel of the given axis in this coordinate.""" assert len(pix) == len(self._coord["crpix"]) self._coord["crpix"] = pix[::-1] def get_referencevalue(self): """Get the reference value of the given axis in this coordinate.""" return self._coord.get("crval", [])[::-1] def set_referencevalue(self, val): """Set the reference pixel of the given axis in this coordinate.""" assert len(val) == len(self._coord["crval"]) self._coord["crval"] = val[::-1] def get_increment(self): """Get the increment of the given axis in this coordinate.""" return self._coord.get("cdelt", [])[::-1] def set_increment(self, inc): """Set the increment of the given axis in this coordinate.""" self._coord["cdelt"] = inc[::-1] def get_unit(self): """Get the unit of the given axis in this coordinate.""" return self._coord.get("units", [])[::-1] def get_axes(self): """Get the axes in this coordinate.""" return self._coord.get("axes", [])[::-1] class directioncoordinate(coordinate): def __init__(self, rec): coordinate.__init__(self, rec) def __str__(self): out = coordinate.__str__(self) out += self._template % ("Frame", str(self.get_frame())) out += self._template % ("Projection", str(self.get_projection())) return out def get_projection(self): """Get the projection of the given axis in this coordinate.""" return self._coord.get("projection", None) def set_projection(self, val): """Set the projection of the given axis in this coordinate. The known projections are SIN, ZEA, TAN, NCP, AIT, ZEA """ knownproj = ["SIN", "ZEA", "TAN", "NCP", "AIT", "ZEA"] # etc assert val.upper() in knownproj self._coord["projection"] = val.upper() def get_frame(self): return self._coord.get("system", None) def set_frame(self, val): # maybe uses measures here # dm = measures();knonwframes = dm.list_codes(dm.direction())["normal"] knownframes = ["GALACTIC", "J2000", "B1950", "SUPERGAL"] # etc assert val.upper() in knownframes self._coord["system"] = val.upper() class spectralcoordinate(coordinate): def __init__(self, rec): coordinate.__init__(self, rec) def __str__(self): out = coordinate.__str__(self) out += self._template % ("Frame", str(self.get_frame())) out += self._template % ("Rest Frequency", str(self.get_restfrequency()) + " Hz") return out def get_unit(self): return self._coord.get("unit", None) def get_referencepixel(self): return self._coord["wcs"].get("crpix", None) def set_referencepixel(self, pix): self._coord["wcs"]["crpix"] = pix def get_referencevalue(self): return self._coord["wcs"].get("crval", None) def set_referencevalue(self, val): self._coord["wcs"]["crval"] = val def get_increment(self): return self._coord["wcs"].get("cdelt", None) def set_increment(self, inc): self._coord["wcs"]["cdelt"] = inc def get_axes(self): return self._coord.get("name", None) def get_restfrequency(self): return self._coord.get("restfreq", None) def set_restfrequency(self, val): self._coord["restfreq"] = val def get_frame(self): return self._coord.get("system", None) def set_frame(self, val): # maybe uses measures here # dm = measures();knonwframes = dm.list_codes(dm.frequency())["normal"] knownframes = ["BARY", "LSRK", "TOPO"] assert val.upper() in knownframes self._coord["system"] = val.upper() def get_conversion(self): return self._coord.get("conversion", None) def set_conversion(self, key, val): assert key in self._coord self._coord["conversion"][key] = val class linearcoordinate(coordinate): def __init__(self, rec): coordinate.__init__(self, rec) class stokescoordinate(coordinate): def __init__(self, rec): coordinate.__init__(self, rec) def get_stokes(self): return self._coord["stokes"] class tabularcoordinate(coordinate): def __init__(self, rec): coordinate.__init__(self, rec) def get_pixelvalues(self): return self._coord["pixelvalues"] def set_pixelvalues(self, val): assert len(val) == len(self._coord["pixelvalues"]) self._coord["pixelvalues"] = val def get_worldvalues(self): return self._coord["worldvalues"] def set_worldvalues(self, val): assert len(val) == len(self._coord["worldvalues"]) self._coord["worldvalues"] = val python-casacore-2.2.1/casacore/images/image.py000066400000000000000000000643231320311315100212720ustar00rootroot00000000000000# image.py: Python image functions # Copyright (C) 2008 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id$ # Make interface to class ImageProxy available. from ._images import Image import numpy try: import numpy.ma as nma except ImportError: import numpy.core.ma as nma from casacore.images.coordinates import coordinatesystem from casacore import six class image(Image): """The Python interface to casacore images. An image can be constructed in a variety of ways: - Opening an existing image. The image format is determined automatically and can be `casacore `_, `HDF5 `_, `FITS `_, or `MIRIAD `_. FITS and MIRIAD always have data type float, but casacore and HDF5 images can have data type float, double, complex, or dcomplex. - Open an image expression by giving a `LEL expression <../../casacore/doc/notes/223.html>`_ string. Note that in an expression `$im` can be used similar to TaQL commands (see function :func:`tables.taql`). - Create a new temporary image from a shape or a numpy array. - Virtually concatenate a number of images along a given axis. This can be used to form a spectral line image cube from separate channel images. The following arguments can be given: `imagename` | It can be given in several forms: | If it is a tuple or list, the image is opened as the virtual concatenation of the given image names or objects. | Otherwise it should be a string giving the image name (or expression). If argument `values` or `shape` is given, a new image with that name is created using the values or shape. If the name is empty, a temporary image is created which can be written later using :func:`saveas`. | Otherwise it is tried to open an existing image with that name. | If the open fails, it is opened as a LEL image expression. `axis` The axis number along which images have to be concatenated. `maskname` | The name of the mask to be used when opening an existing image. If not given, the default image mask is used. | If an image is created, a mask with this name is created. `images` Possible images objects to be used for $n arguments in an expression string. 'values` If given, the image will be created and these values will be stored in it. It should be a numpy array or masked array. If it is a masked array, its mask acts as the `mask` argument described below. The data type of the image is derived from the array's data type. `coordsys` The coordinate system to be used when creating an image. If not given, an appropriate default coordnate system will be used. `overwrite` If False, an exception is raised if the new image file already exists. Default is True. `ashdf5` If True, the image is created in HDF5 format, otherwise in casacore format. Default is casacore format. `mask` | An optional mask to be stored in the image when creating the image. If a mask is given, but no maskname is given, the mask will get the name `mask0`. | Note that the mask can also be given in argument `values` (see above). `shape` If given, the image will be created. If `values` is also given, its shape should match. If `values` is not given, an image with data type double will be created. `tileshape` Advanced users can give the tile shape to be used. See the :mod:`tables` module for more information about Tiled Storage Managers. For example:: im = image('3c343.fits') # open existing fits image im = image('a.img1 - a.img2') # open as expression im = image(shape=(256,256)) # create temp image im = image('a', shape=(256,256)) # create image a """ def __init__(self, imagename, axis=0, maskname="", images=(), values=None, coordsys=None, overwrite=True, ashdf5=False, mask=(), shape=None, tileshape=()): coord = {} if coordsys is not None: coord = coordsys.dict() if isinstance(imagename, Image): # Create from the value returned by subimage, etc. Image.__init__(self, imagename) else: opened = False if isinstance(imagename, tuple) or isinstance(imagename, list): if len(imagename) == 0: raise ValueError('No images given in list or tuple') if isinstance(imagename[0], str): # Concatenate from image names Image.__init__(self, imagename, axis) opened = True elif isinstance(imagename[0], image): # Concatenate from image objects Image.__init__(self, imagename, axis, 0, 0) opened = True if not opened: if not isinstance(imagename, str): raise ValueError("first argument must be name or" + " sequence of images or names") if shape is None: if values is None: # Open an image from name or expression # Copy the tables argument and make sure it is a list imgs = [] for img in images: imgs += [img] try: # Substitute possible $ arguments import casacore.util as cu imagename = cu.substitute(imagename, [(image, '', imgs)], locals=cu.getlocals(3)) except: six.print_("Probably could not import casacore.util") pass Image.__init__(self, imagename, maskname, imgs) else: # Create an image from an array # The values can be a masked array # use the mask if no explicit mask is given if isinstance(values, nma.MaskedArray): if len(mask) == 0: mask = nma.getmaskarray(values) values = values.data if len(mask) > 0: mask = -mask # casa and numpy have opposite flags Image.__init__(self, values, mask, coord, imagename, overwrite, ashdf5, maskname, tileshape) else: # Create an image from a shape (values gives the data type) # default type is float. if values is None: values = numpy.array([0], dtype='float32')[0] Image.__init__(self, shape, values, coord, imagename, overwrite, ashdf5, maskname, tileshape, 0) def __str__(self): """Get image name.""" return self.name(strippath=True) def __len__(self): """Get nr of pixels in the image.""" return self._size() def ispersistent(self): """Test if the image is persistent, i.e. stored on disk.""" return self._ispersistent() def name(self, strippath=False): """Get image name.""" return self._name(strippath) def shape(self): """Get image shape.""" return self._shape() def ndim(self): """Get dimensionality of the image.""" return self._ndim() def size(self): """Get nr of pixels in the image.""" return self._size() def datatype(self): """Get data type of the image.""" return self._datatype() def imagetype(self): """Get image type of the image (PagedImage, HDF5Image, etc.).""" return self._imagetype() def attrgroupnames(self): """Get the names of all attribute groups.""" return self._attrgroupnames() def attrcreategroup(self, groupname): """Create a new attribute group.""" self._attrcreategroup(groupname) def attrnames(self, groupname): """Get the names of all attributes in this group.""" return self._attrnames(groupname) def attrnrows(self, groupname): """Get the number of rows in this attribute group.""" return self._attrnrows(groupname) def attrget(self, groupname, attrname, rownr): """Get the value of an attribute in the given row in a group.""" return self._attrget(groupname, attrname, rownr) def attrgetcol(self, groupname, attrname): """Get the value of an attribute for all rows in a group.""" values = [] for rownr in range(self.attrnrows(groupname)): values.append(self.attrget(groupname, attrname, rownr)) return values def attrfindrows(self, groupname, attrname, value): """Get the row numbers of all rows where the attribute matches the given value.""" values = self.attrgetcol(groupname, attrname) return [i for i in range(len(values)) if values[i] == value] def attrgetrow(self, groupname, key, value=None): """Get the values of all attributes of a row in a group. If the key is an integer, the key is the row number for which the attribute values have to be returned. Otherwise the key has to be a string and it defines the name of an attribute. The attribute values of the row for which the key matches the given value is returned. It can only be used for unique attribute keys. An IndexError exception is raised if no or multiple matches are found. """ if not isinstance(key, str): return self._attrgetrow(groupname, key) # The key is an attribute name whose value has to be found. rownrs = self.attrfindrows(groupname, key, value) if len(rownrs) == 0: raise IndexError("Image attribute " + key + " in group " + groupname + " has no matches for value " + str(value)) if len(rownrs) > 1: raise IndexError("Image attribute " + key + " in group " + groupname + " has multiple matches for value " + str(value)) return self._attrgetrow(groupname, rownrs[0]) def attrgetunit(self, groupname, attrname): """Get the unit(s) of an attribute in a group.""" return self._attrgetunit(groupname, attrname) def attrgetmeas(self, groupname, attrname): """Get the measinfo (type, frame) of an attribute in a group.""" return self._attrgetmeas(groupname, attrname) def attrput(self, groupname, attrname, rownr, value, unit=[], meas=[]): """Put the value and optionally unit and measinfo of an attribute in a row in a group.""" return self._attrput(groupname, attrname, rownr, value, unit, meas) def getdata(self, blc=(), trc=(), inc=()): """Get image data. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to get a data slice. The data is returned as a numpy array. Its dimensionality is the same as the dimensionality of the image, even if an axis has length 1. """ return self._getdata(self._adjustBlc(blc), self._adjustTrc(trc), self._adjustInc(inc)) # Negate the mask; in numpy True means invalid. def getmask(self, blc=(), trc=(), inc=()): """Get image mask. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to get a mask slice. Not all axes need to be specified. Missing values default to begin, end, and 1. The mask is returned as a numpy array. Its dimensionality is the same as the dimensionality of the image, even if an axis has length 1. Note that the casacore images use the convention that a mask value True means good and False means bad. However, numpy uses the opposite. Therefore the mask will be negated, so it can be used directly in numpy operations. If the image has no mask, an array will be returned with all values set to False. """ return numpy.logical_not(self._getmask(self._adjustBlc(blc), self._adjustTrc(trc), self._adjustInc(inc))) # Get data and mask def get(self, blc=(), trc=(), inc=()): """Get image data and mask. Get the image data and mask (see ::func:`getdata` and :func:`getmask`) as a numpy masked array. """ return nma.masked_array(self.getdata(blc, trc, inc), self.getmask(blc, trc, inc)) def putdata(self, value, blc=(), trc=(), inc=()): """Put image data. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to put a data slice. Not all axes need to be specified. Missing values default to begin, end, and 1. The data should be a numpy array. Its dimensionality must be the same as the dimensionality of the image. """ return self._putdata(value, self._adjustBlc(blc), self._adjustInc(inc)) def putmask(self, value, blc=(), trc=(), inc=()): """Put image mask. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to put a data slice. Not all axes need to be specified. Missing values default to begin, end, and 1. The data should be a numpy array. Its dimensionality must be the same as the dimensionality of the image. Note that the casacore images use the convention that a mask value True means good and False means bad. However, numpy uses the opposite. Therefore the mask will be negated, so a numoy masked can be given directly. The mask is not written if the image has no mask and if it the entire mask is False. In that case the mask most likely comes from a getmask operation on an image without a mask. """ # casa and numpy have opposite flags return self._putmask(~value, self._adjustBlc(blc), self._adjustInc(inc)) def put(self, value, blc=(), trc=(), inc=()): """Put image data and mask. Put the image data and optionally the mask (see ::func:`getdata` and :func:`getmask`). If the `value` argument is a numpy masked array, but data and mask will bw written. If it is a normal numpy array, only the data will be written. """ if isinstance(value, nma.MaskedArray): self.putdata(value.data, blc, trc, inc) self.putmask(nma.getmaskarray(value), blc, trc, inc) else: self.putdata(value, blc, trc, inc) def haslock(self, write=False): """Test if the image holds a read or write lock. | See `func:`tables.table.haslock` for more information. | Locks are only used for images in casacore format. For other formats (un)locking is a no-op, so this method always returns True. """ return self._haslock(write) def lock(self, write=False, nattempts=0): """Acquire a read or write lock on the image. | See `func:`tables.table.haslock` for more information. | Locks are only used for images in casacore format. For other formats (un)locking is a no-op, so this method always returns True. Only advanced users should use locking. In normal operations explicit locking and unlocking is not necessary. """ return self._lock(write, nattempts) def unlock(self): """Release a lock on the image. | See `func:`tables.table.haslock` for more information. | Locks are only used for images in casacore format. For other formats (un)locking is a no-op, so this method always returns True. """ return self._unlock() def subimage(self, blc=(), trc=(), inc=(), dropdegenerate=True): """Form a subimage. An image object containing a subset of an image is returned. The arguments blc (bottom left corner), trc (top right corner), and inc (stride) define the subset. Not all axes need to be specified. Missing values default to begin, end, and 1. By default axes with length 1 are left out. A subimage is a so-called virtual image. It is not stored, but only references the original image. It can be made persistent using the :func:`saveas` method. """ return image(self._subimage(self._adjustBlc(blc), self._adjustTrc(trc), self._adjustInc(inc), dropdegenerate)) def coordinates(self): """Get the :class:`coordinatesystem` of the image.""" return coordinatesystem(self._coordinates()) def toworld(self, pixel): """Convert the pixel coordinates of an image value to world coordinates. The coordinates must be given with the slowest varying axis first. Thus normally like frequency(,polarisation axis),Dec,Ra. """ return self._toworld(pixel, True) def topixel(self, world): """Convert the world coordinates of an image value to pixel coordinates. The coordinates must be given with the slowest varying axis first. Thus normally like frequency(,polarisation axis),Dec,Ra. """ return self._topixel(world, True) def imageinfo(self): """Get the standard image info.""" return self._imageinfo() def miscinfo(self): """Get the auxiliary image info.""" return self._miscinfo() def unit(self): """Get the pixel unit of the image.""" return self._unit() def history(self): """Get the image processing history.""" return self._history() def info(self): """Get coordinates, image info, and unit".""" return {'coordinates': self._coordinates(), 'imageinfo': self._imageinfo(), 'miscinfo': self._miscinfo(), 'unit': self._unit() } def tofits(self, filename, overwrite=True, velocity=True, optical=True, bitpix=-32, minpix=1, maxpix=-1): """Write the image to a file in FITS format. `filename` FITS file name `overwrite` If False, an exception is raised if the new image file already exists. Default is True. `velocity` By default a velocity primary spectral axis is written if possible. `optical` If writing a velocity, use the optical definition (otherwise use radio). `bitpix` can be set to -32 (float) or 16 (short) only. When `bitpix` is 16 it will write BSCALE and BZERO into the FITS file. If minPix `minpix` and `maxpix` are used to determine BSCALE and BZERO if `bitpix=16`. If `minpix` is greater than `maxpix` (which is the default), the minimum and maximum pixel values will be determined from the ddta. Oherwise the supplied values will be used and pixels outside that range will be clipped to the minimum and maximum pixel values. Note that this truncation does not occur for `bitpix=-32`. """ return self._tofits(filename, overwrite, velocity, optical, bitpix, minpix, maxpix) def saveas(self, filename, overwrite=True, hdf5=False, copymask=True, newmaskname="", newtileshape=()): """Write the image to disk. Note that the created disk file is a snapshot, so it is not updated for possible later changes in the image object. `overwrite` If False, an exception is raised if the new image file already exists. Default is True. `ashdf5` If True, the image is created in HDF5 format, otherwise in casacore format. Default is casacore format. `copymask` By default the mask is written as well if the image has a mask. 'newmaskname` If the mask is written, the name is the same the original or `mask0` if the original mask has no name. Using this argument a different mask name can be given. `tileshape` Advanced users can give a new tile shape. See the :mod:`tables` module for more information about Tiled Storage Managers. """ self._saveas(filename, overwrite, hdf5, copymask, newmaskname, newtileshape) def statistics(self, axes=(), minmaxvalues=(), exclude=False, robust=True): """Calculate statistics for the image. Statistics are returned in a dict for the given axes. E.g. if axes [0,1] is given in a 3-dim image, the statistics are calculated for each plane along the 3rd axis. By default statistics are calculated for the entire image. `minmaxvalues` can be given to include or exclude pixels with values in the given range. If only one value is given, min=-abs(val) and max=abs(val). By default robust statistics (Median, MedAbsDevMed, and Quartile) are calculated too. """ return self._statistics(self._adaptAxes(axes), "", minmaxvalues, exclude, robust) def regrid(self, axes, coordsys, outname="", overwrite=True, outshape=(), interpolation="linear", decimate=10, replicate=False, refchange=True, forceregrid=False): """Regrid the image to a new image object. Regrid the image on the given axes to the given coordinate system. The output is stored in the given file; it no file name is given a temporary image is made. If the output shape is empty, the old shape is used. `replicate=True` means replication rather than regridding. """ return image(self._regrid(self._adaptAxes(axes), outname, overwrite, outshape, coordsys.dict(), interpolation, decimate, replicate, refchange, forceregrid)) def view(self, tempname='/tmp/tempimage'): """Display the image using casaviewer. If the image is not persistent, a copy will be made that the user has to delete once viewing has finished. The name of the copy can be given in argument `tempname`. Default is '/tmp/tempimage'. """ import os # Test if casaviewer can be found. # On OS-X 'which' always returns 0, so use test on top of it. if os.system('test -x `which casaviewer` > /dev/null 2>&1') == 0: six.print_("Starting casaviewer in the background ...") self.unlock() if self.ispersistent(): os.system('casaviewer ' + self.name() + ' &') elif len(tempname) > 0: six.print_(" making a persistent copy in " + tempname) six.print_(" which should be deleted after the viewer has ended") self.saveas(tempname) os.system('casaviewer ' + tempname + ' &') else: six.print_("Cannot view because the image is in memory only.") six.print_("You can browse a persistent copy of the image like:") six.print_(" t.view('/tmp/tempimage')") else: six.print_("casaviewer cannot be found") def _adaptAxes(self, axes): # If axes is a single integer value, turn it into a list. if isinstance(axes, int): axes = [axes] # ImageProxy expects Fortran-numbered axes. # So reverse the axes. n = self.ndim() - 1 axout = [] for i in range(len(axes), 0, -1): axout += [n - axes[i - 1]] return axout def _adjust(self, val, defval): retval = defval if isinstance(val, tuple) or isinstance(val, list): retval[0:len(val)] = val else: retval[0] = val return retval # Append blc with 0 if shorter than shape. def _adjustBlc(self, blc): shp = self._shape() return self._adjust(blc, [0 for x in shp]) # Append trc with shape-1 if shorter than shape. def _adjustTrc(self, trc): shp = self._shape() return self._adjust(trc, [x - 1 for x in shp]) # Append inc with 1 if shorter than shape. def _adjustInc(self, inc): shp = self._shape() return self._adjust(inc, [1 for x in shp]) python-casacore-2.2.1/casacore/measures/000077500000000000000000000000001320311315100202055ustar00rootroot00000000000000python-casacore-2.2.1/casacore/measures/__init__.py000077500000000000000000001056041320311315100223270ustar00rootroot00000000000000# __init__.py: Top level .py file for python measures interface # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: __init__.py,v 1.2 2006/12/04 04:01:03 mmarquar Exp $ __all__ = ['is_measure', 'measures'] from ._measures import measures as _measures import casacore.quanta as dq import os if 'MEASURESDATA' in os.environ.keys(): if 'AIPSPATH' not in os.environ.keys(): os.environ['AIPSPATH'] = '%s dummy dummy' % os.environ['MEASURESDATA'] def is_measure(v): """ Return if this is a true measures dictionary :param v: The object to check """ if isinstance(v, dict) and v.has_key("type") and v.has_key("m0"): return True return False def _check_valid_offset(self, mtype): if not off['type'] == mtype: raise TypeError('Illegal offset type specified.') class measures(_measures): """The measures server object. This should be used to set frame information and create the various measures and do conversion on them. The measures types are: * :meth:`direction` * :meth:`position` * :meth:`epoch` * :meth:`frequency` * :meth:`doppler` * :meth:`baseline` * :meth:`radialvelocity` * :meth:`uvw` * :meth:`earthmagnetic` Typical usage:: from casacore.measures import measures dm = measures() # create measures server instance dirmeas = dm.direction() """ def __init__(self): _measures.__init__(self) self._framestack = {} def set_data_path(self, pth): """Set the location of the measures data directory. :param pth: The absolute path to the measures data directory. """ if os.path.exists(pth): if not os.path.exists(os.path.join(pth, 'data', 'geodetic')): raise IOError("The given path doesn't contain a 'data' " "subdirectory") os.environ["AIPSPATH"] = "%s dummy dummy" % pth def measure(self, v, rf, off=None): """Create/convert a measure using the frame state set on the measures server instance (via :meth:`do_frame`) :param v: The measure to convert :param rf: The frame reference to convert to :param off: The optional offset for the measure """ if off is None: off = {} keys = ["m0", "m1", "m2"] for key in keys: if key in v: if dq.is_quantity(v[key]): v[key] = v[key].to_dict() return _measures.measure(self, v, rf, off) def direction(self, rf='', v0='0..', v1='90..', off=None): """Defines a direction measure. It has to specify a reference code, direction quantity values (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a direction. :param rf: reference code string; allowable reference codes are: J2000 JMEAN JTRUE APP B1950 BMEAN BTRUE GALACTIC HADEC AZEL SUPERGAL ECLIPTIC MECLIPTIC TECLIPTIC MERCURY VENUS MARS JUPITER SATURN URANUS NEPTUNE PLUTO MOON SUN COMET. Note that additional ones may become available. Check with:: dm.list_codes(dm.direction()) :param v0, v1: Direction quantity values should be longitude (angle) and latitude (angle) or strings parsable by :func:`~casacore.quanta.quantity`. None are needed for planets: the frame epoch defines coordinates. See :func:`~casacore.quanta.quantity` for possible angle formats. :param off: an optional offset measure of same type Example:: >>> dm.direction('j2000','30deg','40deg') >>> dm.direction('mars') """ loc = {'type': 'direction', 'refer': rf} loc['m0'] = dq.quantity(v0) loc['m1'] = dq.quantity(v1) if is_measure(off): if not off['type'] == "direction": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def position(self, rf='', v0='0..', v1='90..', v2='0m', off=None): """Defines a position measure. It has to specify a reference code, position quantity values (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a position. Note that additional ones may become available. Check with:: dm.list_codes(dm.position()) The position quantity values should be either longitude (angle), latitude(angle) and height(length); or x,y,z (length). See :func:`~casacore.quanta.quantity` for possible angle formats. :param rf: reference code string; Allowable reference codes are: *WGS84* *ITRF* (World Geodetic System and International Terrestrial Reference Frame) :param v0: longitude or x as quantity or string :param v1: latitude or y as quantity or string :param v2: height or z as quantity or string :param off: an optional offset measure of same type Example:: dm.position('wgs84','30deg','40deg','10m') dm.observatory('ATCA') """ loc = {'type': 'position', 'refer': rf} loc['m0'] = dq.quantity(v0) loc['m1'] = dq.quantity(v1) loc['m2'] = dq.quantity(v2) if is_measure(off): if not off['type'] == "position": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def epoch(self, rf='', v0='0.0d', off=None): """ Defines an epoch measure. It has to specify a reference code, an epoch quantity value (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be an epoch. :param rf: reference code string; Allowable reference codes are: *UTC TAI LAST LMST GMST1 GAST UT1 UT2 TDT TCG TDB TCB* Note that additional ones may become available. Check with:: dm.list_codes(dm.position()) :param v0: time as quantity or string :param off: an optional offset measure of same type """ loc = {'type': 'epoch', 'refer': rf} loc['m0'] = dq.quantity(v0) if is_measure(off): if not off['type'] == "epoch": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def frequency(self, rf='', v0='0Hz', off=None): """Defines a frequency measure. It has to specify a reference code, frequency quantity value (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a frequency. :param rf: reference code string; Allowable reference codes are: *REST LSRK LSRD BARY GEO TOPO GALACTO* Note that additional ones may become available. Check with:: dm.list_codes(dm.frequency()) :param v0: frequency value as quantity or string. The frequency quantity values should be in one of the recognised units (examples all give same frequency): * value with time units: a period (0.5s) * value as frequency: 2Hz * value in angular frequency: 720deg/s * value as length: 149896km * value as wave number: 4.19169e-8m-1 * value as enery (h.nu): 8.27134e-9ueV * value as momentum: 4.42044e-42kg.m :param off: an optional offset measure of same type """ loc = {'type': "frequency", 'refer': rf, 'm0': dq.quantity(v0)} if is_measure(off): if not off['type'] == "frequency": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def doppler(self, rf='', v0=0.0, off=None): """Defines a doppler measure. It has to specify a reference code, doppler quantity value (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a doppler. :param rf: reference code string; Allowable reference codes are: *RADIO OPTICAL Z RATIO RELATIVISTIC BETA GAMMA*. Note that additional ones may become available. Check with:: dm.list_codes(dm.doppler()) :param v0: doppler ratio as quantity, string or float value. It should be either non-dimensioned to specify a ratio of the light velocity, or in velocity. (examples all give same doppler): :param off: an optional offset measure of same type Example:: >>> from casacore import quanta >>> dm.doppler('radio', 0.4) >>> dm.doppler('radio', '0.4') >>> dm.doppler('RADIO', quanta.constants['c']*0.4)) """ if isinstance(v0, float): v0 = str(v0) loc = {'type': "doppler", 'refer': rf, 'm0': dq.quantity(v0)} if is_measure(off): if not off['type'] == "doppler": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def radialvelocity(self, rf='', v0='0m/s', off=None): """Defines a radialvelocity measure. It has to specify a reference code, radialvelocity quantity value (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a radialvelocity. :param rf: reference code string; Allowable reference codes are: *LSRK LSRD BARY GEO TOPO GALACTO* Note that additional ones may become available. Check with:: dm.list_codes(dm.radialvelocity()) :param v0: longitude or x as quantity or string :param off: an optional offset measure of same type """ loc = {'type': "radialvelocity", 'refer': rf, 'm0': dq.quantity(v0)} if is_measure(off): if not off['type'] == "radialvelocity": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def baseline(self, rf='', v0='0..', v1='', v2='', off=None): """Defines a baselin measure. It has to specify a reference code, uvw quantity values (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a baseline. :param rf: reference code string; Allowable reference codes are: *ITRF* and :meth:`direction` codes Note that additional ones may become available. Check with:: dm.list_codes(dm.baseline()) :param v0: longitude or x as quantity or string :param v1: latitude or y as quantity or string :param v2: height or z as quantity or string :param off: an optional offset measure of same type """ loc = {'type': "baseline", 'refer': rf} loc['m0'] = dq.quantity(v0) loc['m1'] = dq.quantity(v1) loc['m2'] = dq.quantity(v2) if is_measure(off): if not off['type'] == "doppler": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def uvw(self, rf='', v0='0..', v1='', v2='', off=None): """Defines a uvw measure. It has to specify a reference code, uvw quantity values (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given), and optionally it can specify an offset, which in itself has to be a uvw. :param rf: reference code string; Allowable reference codes are: *ITRF* and :meth:`direction` codes Note that additional ones may become available. Check with:: dm.list_codes(dm.uvw()) :param v0: longitude or x as quantity or string :param v1: latitude or y as quantity or string :param v2: height or z as quantity or string :param off: an optional offset measure of same type """ loc = {'type': "uvw", 'refer': rf} loc['m0'] = dq.quantity(v0) loc['m1'] = dq.quantity(v1) loc['m2'] = dq.quantity(v2) if is_measure(off): if not off['type'] == "uvw": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def earthmagnetic(self, rf='', v0='0G', v1='0..', v2='90..', off=None): """Defines an earthmagnetic measure. It needs a reference code, earthmagnetic quantity values (see introduction for the action on a scalar quantity with either a vector or scalar value, and when a vector of quantities is given) if the reference code is not for a model, and optionally it can specify an offset, which in itself has to be a earthmagnetic. In general you specify a model (*IGRF* is the default and the only one known) and convert it to an explicit field. (See http://fdd.gsfc.nasa.gov/IGRF.html for information on the International Geomagnetic Reference Field). The earthmagnetic quantity values should be either longitude (angle), latitude(angle) and length(field strength); or x,y,z (field). See :func:`~casacore.quanta.quantity` for possible angle formats. :param rf: reference code string; Allowable reference codes are: *IGRF* :param v0: longitude or x as quantity or string :param v1: latitude or y as quantity or string :param v2: height or z as quantity or string :param off: an optional offset measure of same type """ loc = {'type': "earthmagnetic", 'refer': rf} loc['m0'] = dq.quantity(v0) loc['m1'] = dq.quantity(v1) loc['m2'] = dq.quantity(v2) if is_measure(off): if not off['type'] == "earthmagnetic": raise TypeError('Illegal offset type specified.') loc["offset"] = off return self.measure(loc, rf) def tofrequency(self, rf, v0, rfq): """Convert a Doppler type value (e.g. in radio mode) to a frequency. The type of frequency (e.g. LSRK) and a rest frequency (either as a frequency quantity (e.g. ``dm.constants('HI'))`` or a frequency measure (e.g. ``dm.frequency('rest','5100MHz'))`` should be specified. :param rf: frequency reference code (see :meth:`frequency`) :param v0: a doppler measure :param rfq: frequency measure or quantity Example:: dop = dm.doppler('radio',0.4) freq = dm.tofrequency('lsrk', dop, dm.constants('HI')) """ if is_measure(rfq) and rfq['type'] == 'frequency': rfq = dq.quantity(rfq['m0']) elif isinstance(rfq, str): rfq = dq.quantity(rfq) if is_measure(v0) and v0['type'] == 'doppler' \ and dq.is_quantity(rfq) \ and rfq.conforms(dq.quantity('Hz')): return self.doptofreq(v0, rf, rfq) else: raise TypeError('Illegal Doppler or rest frequency specified') to_frequency = tofrequency def torestfrequency(self, f0, d0): """Convert a frequency measure and a doppler measure (e.g. obtained from another spectral line with a known rest frequency) to a rest frequency. :param f0: frequency reference code (see :meth:`frequency`) :param v0: a doppler measure Example:: dp = dm.doppler('radio', '2196.24984km/s') # a measured doppler speed f = dm.frequency('lsrk','1410MHz') # a measured frequency dm.torestfrequency(f, dp) # the corresponding rest frequency """ if is_measure(f0) and f0['type'] == 'frequency' \ and is_measure(d0) and d0['type'] == 'doppler': return self.torest(f0, d0) else: raise TypeError('Illegal Doppler or rest frequency specified') to_restfrequency = torestfrequency def todoppler(self, rf, v0, rfq): """Convert a radialvelocity measure or a frequency measure to a doppler measure. In the case of a frequency, a rest frequency has to be specified. The type of doppler wanted (e.g. *RADIO*) has to be specified. :param rf: doppler reference code (see :meth:`doppler`) :param v0: a radialvelocity or frequency measure :param rfq: frequency measure or quantity Example:: f = dm.frequency('lsrk','1410MHz') # specify a frequency dm.todoppler('radio', f, dm.constants('HI')) # give doppler, using HI rest """ if is_measure(rfq) and rfq['type'] == 'frequency': rfq = dq.quantity(rfq['m0']) elif isinstance(rfq, str): rfq = dq.quantity(rfq) if is_measure(v0): if v0['type'] == 'radialvelocity': return self.todop(v0, dq.quantity(1., 'Hz')) elif v0['type'] == 'frequency' and dq.is_quantity(rfq) \ and rfq.conforms(dq.quantity('Hz')): return self.todop(v0, rfq) else: raise TypeError('Illegal Doppler or rest frequency specified') else: raise TypeError('Illegal Frequency specified') to_doppler = todoppler def toradialvelocity(self, rf, v0): """Convert a Doppler type value (e.g. in radio mode) to a real radialvelocity. The type of velocity (e.g. *LSRK*) should be specified :param rf: radialvelocity reference code (see :meth:`radialvelocity`) :param v0: a doppler measure Example:: a = dm.doppler('radio',0.4) dm.toradialvelocity('topo',a) """ if is_measure(v0) and v0['type'] == 'doppler': return self.doptorv(rf, v0) else: raise TypeError('Illegal Doppler specified') to_radialvelocity = toradialvelocity def touvw(self, v): """Calculates a uvw measure from a baseline. The baseline can consist of a vector of actual baseline positions. Note that the baseline does not have to be a proper baseline, but can be a series of positions (to call positions baselines see :meth:`asbaseline` ) for speed reasons: operations are linear and can be done on positions, which are converted to baseline values at the end (with :meth:`expand` ). Whatever the reference code of the baseline, the returned uvw will be given in J2000. If the dot argument is given, that variable will be filled with a quantity array consisting of the time derivative of the uvw (note that only the sidereal rate is taken into account; not precession, earth tides and similar variations, which are much smaller). If the xyz variable is given, it will be filled with the quantity values of the uvw measure. The values of the input baselines can be given as a quantity vector per x, y or z value. uvw coordinates are calculated for a certain direction in the sky hence the frame has to contain the direction for the calculation to work. Since the baseline and the sky rotate with respect of each other, the time should be specified as well. Example:: >>> dm.do_frame(dm.observatory('atca')) >>> dm.do_frame(dm.source('1934-638')) >>> dm.do_frame(dm.epoch('utc', 'today')) >>> b = dm.baseline('itrf', '10m', '20m', '30m') """ if is_measure(v) and v['type'] == 'baseline': m = _measures.uvw(self, v) m['xyz'] = dq.quantity(m['xyz']) m['dot'] = dq.quantity(m['dot']) return m else: raise TypeError('Illegal Baseline specified') to_uvw = touvw def expand(self, v): """Calculates the differences between a series of given measure values: it calculates baseline values from position values. :params v: a measure (of type 'baseline', 'position' or 'uvw') :returns: a `dict` with the value for key `measures` being a measure and the value for key `xyz` a quantity containing the differences. Example:: >>> from casacore.quanta import quantity >>> x = quantity([10,50],'m') >>> y = quantity([20,100],'m') >>> z = quantity([30,150],'m') >>> sb = dm.baseline('itrf', x, y, z) >>> out = dm.expand(sb) >>> print out['xyz'] [40.000000000000014, 80.0, 120.0] m """ if not is_measure(v) or v['type'] not in ['baseline', 'position', 'uvw']: raise TypeError("Can only expand baselines, positions, or uvw") vw = v.copy() vw['type'] = "uvw" vw['refer'] = "J2000" outm = _measures.expand(self, vw) outm['xyz'] = dq.quantity(outm['xyz']) outm['measure']['type'] = v['type'] outm['measure']['refer'] = v['refer'] return outm def asbaseline(self, pos): """Convert a position measure into a baseline measure. No actual baseline is calculated, since operations can be done on positions, with subtractions to obtain baselines at a later stage. :param pos: a position measure :returns: a baseline measure """ if not is_measure(pos) or pos['type'] not in ['position', 'baseline']: raise TypeError('Argument is not a position/baseline measure') if pos['type'] == 'position': loc = self.measure(pos, 'itrf') loc['type'] = 'baseline' return self.measure(loc, 'j2000') return pos as_baseline = asbaseline def getvalue(self, v): """ Return a list of quantities making up the measures' value. :param v: a measure """ if not is_measure(v): raise TypeError('Incorrect input type for getvalue()') import re rx = re.compile("m\d+") out = [] keys = v.keys()[:] keys.sort() for key in keys: if re.match(rx, key): out.append(dq.quantity(v.get(key))) return out get_value = getvalue def get_type(self, m): """Get the type of the measure. :param m: a measure (dictionary) :rtype: string """ if is_measure(m): return m["type"] else: raise TypeError("Argument is not a measure") def get_ref(self, m): """Get the reference frame of the measure. :param m: a measure (dictionary) :rtype: string """ if is_measure(m): return m["refer"] else: raise TypeError("Argument is not a measure") def get_offset(self, m): """Get the offset measure. :param m: a measure (dictionary) :rtype: a measure """ if is_measure(m): return m.get("offset", None) else: raise TypeError("Argument is not a measure") def doframe(self, v): """This method will set the measure specified as part of a frame. If conversion from one type to another is necessary (with the measure function), the following frames should be set if one of the reference types involved in the conversion is as in the following lists: **Epoch** * UTC * TAI * LAST - position * LMST - position * GMST1 * GAST * UT1 * UT2 * TDT * TCG * TDB * TCD **Direction** * J2000 * JMEAN - epoch * JTRUE - epoch * APP - epoch * B1950 * BMEAN - epoch * BTRUE - epoch * GALACTIC * HADEC - epoch, position * AZEL - epoch, position * SUPERGALACTIC * ECLIPTIC * MECLIPTIC - epoch * TECLIPTIC - epoch * PLANET - epoch, [position] **Position** * WGS84 * ITRF **Radial Velocity** * LSRK - direction * LSRD - direction * BARY - direction * GEO - direction, epoch * TOPO - direction, epoch, position * GALACTO - direction * **Doppler** * RADIO * OPTICAL * Z * RATIO * RELATIVISTIC * BETA * GAMMA * **Frequency** * REST - direction, radialvelocity * LSRK - direction * LSRD - direction * BARY - direction * GEO - direction, epoch * TOPO - direction, epoch, position * GALACTO """ if not is_measure(v): raise TypeError('Argument is not a measure') if (v["type"] == "frequency" and v["refer"].lower() == "rest") \ or _measures.doframe(self, v): self._framestack[v["type"]] = v return True return False do_frame = doframe def _fillnow(self): if not "epoch" in self._framestack \ or not is_measure(self._framestack["epoch"]): self.frame_now() def _getwhere(self): if not self._framestack.has_key("position") \ or not is_measure(self._framestack["position"]): raise RuntimeError("Can't find position frame") return self._framestack["position"] def framenow(self): """Set the time (epoch) frame to the current time and day.""" self.do_frame(self.epoch("UTC", "today")) frame_now = framenow def rise(self, crd, ev='5deg'): """This method will give the rise/set hour-angles of a source. It needs the position in the frame, and a time. If the latter is not set, the current time will be used. :param crd: a direction measure :param ev: the elevation limit as a quantity or string :returns: `dict` with rise and set sidereal time quantities or a 2 strings "below" or "above" """ if not is_measure(crd): raise TypeError('No rise/set coordinates specified') ps = self._getwhere() self._fillnow() hd = self.measure(crd, "hadec") c = self.measure(crd, "app") evq = dq.quantity(ev) hdm1 = dq.quantity(hd["m1"]) psm1 = dq.quantity(ps["m1"]) ct = (dq.sin(dq.quantity(ev)) - (dq.sin(hdm1) * dq.sin(psm1))) \ / (dq.cos(hdm1) * dq.cos(psm1)) if ct.get_value() >= 1: return {'rise': 'below', 'set': 'below'} if ct.get_value() <= -1: return {'rise': 'above', 'set': 'above'} a = dq.acos(ct) return dict(rise=dq.quantity(c["m0"]).norm(0) - a, set=dq.quantity(c["m0"]).norm(0) + a) def riseset(self, crd, ev="5deg"): """This will give the rise/set times of a source. It needs the position in the frame, and a time. If the latter is not set, the current time will be used. :param crd: a direction measure :param ev: the elevation limit as a quantity or string :returns: The returned value is a `dict` with a 'solved' key, which is `False` if the source is always below or above the horizon. In that case the rise and set fields will all have a string value. The `dict` also returns a rise and set `dict`, with 'last' and 'utc' keys showing the rise and set times as epochs. """ a = self.rise(crd, ev) if isinstance(a['rise'], str): return {"rise": {"last": a[0], "utc": a[0]}, "set": {"last": a[1], "utc": a[1]}, "solved": False} ofe = self.measure(self._framestack["epoch"], "utc") if not is_measure(ofe): ofe = self.epoch('utc', 'today') x = a.copy() for k in x: x[k] = self.measure( self.epoch("last", a[k].totime(), off=self.epoch("r_utc", (dq.quantity(ofe["m0"]) + dq.quantity("0.5d") )) ), "utc") return {"rise": {"last": self.epoch("last", a["rise"].totime()), "utc": x["rise"]}, "set": {"last": self.epoch("last", a["set"].totime()), "utc": x["set"]}, "solved": True } def observatory(self, name): """Get a (position) measure for the given obervatory. :param name: the name of the observatory. At the time of writing the following observatories are recognised (but check :meth:`get_observatories`): *ALMA ATCA BIMA CLRO DRAO DWL GB JCMT MOPRA NRAO12M PKS VLA WSRT* :returns: a position measure """ return _measures.observatory(self, name.upper()) def get_observatories(self): """Return a list of known observatory names, which can be used as input to :meth:`observatory`. :rtype: list of strings """ return self.obslist() def line(self, name): """Get a (frequency) measure for the given spectral line name. :param name: the name of the spectral line. Minimum match applies. At the time of writing the following are recognised (but check :meth:`get_lines`): *C109A CI CII166A DI H107A H110A H138B H166A H240A H272A H2CO HE110A HE138B HI OH1612 OH1665 OH1667 OH1720 CO115271 H2O22235 SiO86847 CO230538* :returns: a frequency measure """ return _measures.line(self, name) def get_lines(self): """Return a list of known spectral line names, which can be used as input to :meth:`line`. :rtype: list of strings """ return self.linelist() def source(self, name): """Get a (direction) measure for the given atsronomical source. :param name: the name of the source. Minimum match applies. Check :meth:`get_sources` for the list of known sources :returns: a frequency measure Example:: >>> print dm.source('1936-6') {'m0': {'unit': 'rad', 'value': -1.1285176426372401}, 'm1': {'unit': 'rad', 'value': -1.0854059868642842}, 'refer': 'ICRS', 'type': 'direction'} """ return _measures.source(self, name) def get_sources(self): """Return a list of known sources names, which can be used as input to :meth:`source`. :rtype: list of strings """ return self.srclist() # alias def list_codes(self, m): """Get the known reference codes for a specified measure type. It will return a `dict` with two keys. The first is a string list of all normal codes; the second a string list (maybe empty) with all extra codes (like planets). :param m: the measures with the type to get codes for """ return _measures.alltyp(self, m) def posangle(self, m0, m1): """ This method will give the position angle from a direction to another i.e. the angle in a direction between the direction to the North pole and the other direction. :param m0: a measure :param m1: another measure Example:: >>> a = dm.direction('j2000','0deg','70deg') >>> b = dm.direction('j2000','0deg','80deg') >>> print dm.posangle(a,b) -0.0 deg """ return _measures.posangle(self, m0, m1) def separation(self, m0, m1): """ This method will give the separation of a direction from another as an angle. :param m0: a measure :param m1: another measure Example:: >>> a = dm.direction('j2000','0deg','70deg') >>> b = dm.direction('j2000','0deg','80deg') >>> print dm.separation(a,b) 10.0 deg """ return _measures.separation(self, m0, m1) ## def show(v, refcode=True): ## z = "" ## if is_measure(v): ## x = dm.gettype(v) ## y = dm.getvalue(v) ## if x.startswith("epo"): ## z = dq.form.dtime(y[0]) ## else: ## return "" ## if refcode: ## return [z, dm.getref(v)] ## return z python-casacore-2.2.1/casacore/quanta/000077500000000000000000000000001320311315100176525ustar00rootroot00000000000000python-casacore-2.2.1/casacore/quanta/__init__.py000066400000000000000000000002641320311315100217650ustar00rootroot00000000000000from ._quanta import * from .quantity import quantity, is_quantity constants = constants() units = units() prefixes = prefixes() del Quantity, QuantVec, from_string, from_dict_v python-casacore-2.2.1/casacore/quanta/quantity.py000066400000000000000000000035461320311315100221120ustar00rootroot00000000000000from ._quanta import QuantVec from ._quanta import Quantity from ._quanta import from_string, from_dict, from_dict_v def is_quantity(q): """Indicate whether the object is a valid quantity""" return isinstance(q, QuantVec) or isinstance(q, Quantity) # Quantity returns new Quantities, so we need to insert these # functions into Quantity def new_get_value(quant, *args): val = QuantVec._get_value(quant, *args) if len(val) == 1: return val[0] else: return val QuantVec.get_value = new_get_value def to_string(quant, fmt="%0.5f"): val = quant.get_value() if hasattr(val, "__len__"): fmt = "[" + ", ".join([fmt % i for i in val]) + "] %s" return fmt % quant.get_unit() fmt += " %s" return fmt % (val, quant.get_unit()) QuantVec.to_string = to_string Quantity.to_string = to_string QuantVec.__str__ = to_string Quantity.__str__ = to_string # QuantVec.__repr__ = to_string # Quantity.__repr__ = to_string def quantity(*args): """Create a quantity. This can be from a scalar or vector. Example:: q1 = quantity(1.0, "km/s") q2 = quantity("1km/s") q1 = quantity([1.0,2.0], "km/s") """ if len(args) == 1: if isinstance(args[0], str): # use copy constructor to create quantity from string return Quantity(from_string(args[0])) elif isinstance(args[0], dict): if hasattr(args[0]["value"], "__len__"): return QuantVec(from_dict_v(args[0])) else: return Quantity(from_dict(args[0])) elif isinstance(args[0], Quantity) or isinstance(args[0], QuantVec): return args[0] else: raise TypeError("Invalid argument type for") else: if hasattr(args[0], "__len__"): return QuantVec(*args) else: return Quantity(*args) python-casacore-2.2.1/casacore/six.py000066400000000000000000000665321320311315100175520ustar00rootroot00000000000000"""Utilities for writing code that runs on Python 2 and 3""" # Copyright (c) 2010-2014 Benjamin Peterson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from __future__ import absolute_import import functools import itertools import operator import sys import types __author__ = "Benjamin Peterson " __version__ = "1.8.0" # Useful for very coarse version differentiation. PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY3: string_types = str, integer_types = int, class_types = type, text_type = str binary_type = bytes MAXSIZE = sys.maxsize else: string_types = basestring, integer_types = (int, long) class_types = (type, types.ClassType) text_type = unicode binary_type = str if sys.platform.startswith("java"): # Jython always uses 32 bits. MAXSIZE = int((1 << 31) - 1) else: # It's possible to have sizeof(long) != sizeof(Py_ssize_t). class X(object): def __len__(self): return 1 << 31 try: len(X()) except OverflowError: # 32-bit MAXSIZE = int((1 << 31) - 1) else: # 64-bit MAXSIZE = int((1 << 63) - 1) del X def _add_doc(func, doc): """Add documentation to a function.""" func.__doc__ = doc def _import_module(name): """Import module, returning the module after the last dot.""" __import__(name) return sys.modules[name] class _LazyDescr(object): def __init__(self, name): self.name = name def __get__(self, obj, tp): result = self._resolve() setattr(obj, self.name, result) # Invokes __set__. try: # This is a bit ugly, but it avoids running this again by # removing this descriptor. delattr(obj.__class__, self.name) except AttributeError: pass return result class MovedModule(_LazyDescr): def __init__(self, name, old, new=None): super(MovedModule, self).__init__(name) if PY3: if new is None: new = name self.mod = new else: self.mod = old def _resolve(self): return _import_module(self.mod) def __getattr__(self, attr): _module = self._resolve() value = getattr(_module, attr) setattr(self, attr, value) return value class _LazyModule(types.ModuleType): def __init__(self, name): super(_LazyModule, self).__init__(name) self.__doc__ = self.__class__.__doc__ def __dir__(self): attrs = ["__doc__", "__name__"] attrs += [attr.name for attr in self._moved_attributes] return attrs # Subclasses should override this _moved_attributes = [] class MovedAttribute(_LazyDescr): def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): super(MovedAttribute, self).__init__(name) if PY3: if new_mod is None: new_mod = name self.mod = new_mod if new_attr is None: if old_attr is None: new_attr = name else: new_attr = old_attr self.attr = new_attr else: self.mod = old_mod if old_attr is None: old_attr = name self.attr = old_attr def _resolve(self): module = _import_module(self.mod) return getattr(module, self.attr) class _SixMetaPathImporter(object): """ A meta path importer to import six.moves and its submodules. This class implements a PEP302 finder and loader. It should be compatible with Python 2.5 and all existing versions of Python3 """ def __init__(self, six_module_name): self.name = six_module_name self.known_modules = {} def _add_module(self, mod, *fullnames): for fullname in fullnames: self.known_modules[self.name + "." + fullname] = mod def _get_module(self, fullname): return self.known_modules[self.name + "." + fullname] def find_module(self, fullname, path=None): if fullname in self.known_modules: return self return None def __get_module(self, fullname): try: return self.known_modules[fullname] except KeyError: raise ImportError("This loader does not know module " + fullname) def load_module(self, fullname): try: # in case of a reload return sys.modules[fullname] except KeyError: pass mod = self.__get_module(fullname) if isinstance(mod, MovedModule): mod = mod._resolve() else: mod.__loader__ = self sys.modules[fullname] = mod return mod def is_package(self, fullname): """ Return true, if the named module is a package. We need this method to get correct spec objects with Python 3.4 (see PEP451) """ return hasattr(self.__get_module(fullname), "__path__") def get_code(self, fullname): """Return None Required, if is_package is implemented""" self.__get_module(fullname) # eventually raises ImportError return None get_source = get_code # same as get_code _importer = _SixMetaPathImporter(__name__) class _MovedItems(_LazyModule): """Lazy loading of moved objects""" __path__ = [] # mark as package _moved_attributes = [ MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), MovedAttribute("intern", "__builtin__", "sys"), MovedAttribute("map", "itertools", "builtins", "imap", "map"), MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("reload_module", "__builtin__", "imp", "reload"), MovedAttribute("reduce", "__builtin__", "functools"), MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), MovedAttribute("StringIO", "StringIO", "io"), MovedAttribute("UserDict", "UserDict", "collections"), MovedAttribute("UserList", "UserList", "collections"), MovedAttribute("UserString", "UserString", "collections"), MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), MovedModule("builtins", "__builtin__"), MovedModule("configparser", "ConfigParser"), MovedModule("copyreg", "copy_reg"), MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), MovedModule("http_cookies", "Cookie", "http.cookies"), MovedModule("html_entities", "htmlentitydefs", "html.entities"), MovedModule("html_parser", "HTMLParser", "html.parser"), MovedModule("http_client", "httplib", "http.client"), MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), MovedModule("cPickle", "cPickle", "pickle"), MovedModule("queue", "Queue"), MovedModule("reprlib", "repr"), MovedModule("socketserver", "SocketServer"), MovedModule("_thread", "thread", "_thread"), MovedModule("tkinter", "Tkinter"), MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), MovedModule("tkinter_tix", "Tix", "tkinter.tix"), MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), MovedModule("tkinter_colorchooser", "tkColorChooser", "tkinter.colorchooser"), MovedModule("tkinter_commondialog", "tkCommonDialog", "tkinter.commondialog"), MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), MovedModule("tkinter_font", "tkFont", "tkinter.font"), MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", "tkinter.simpledialog"), MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), MovedModule("winreg", "_winreg"), ] for attr in _moved_attributes: setattr(_MovedItems, attr.name, attr) if isinstance(attr, MovedModule): _importer._add_module(attr, "moves." + attr.name) del attr _MovedItems._moved_attributes = _moved_attributes moves = _MovedItems(__name__ + ".moves") _importer._add_module(moves, "moves") class Module_six_moves_urllib_parse(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_parse""" _urllib_parse_moved_attributes = [ MovedAttribute("ParseResult", "urlparse", "urllib.parse"), MovedAttribute("SplitResult", "urlparse", "urllib.parse"), MovedAttribute("parse_qs", "urlparse", "urllib.parse"), MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), MovedAttribute("urldefrag", "urlparse", "urllib.parse"), MovedAttribute("urljoin", "urlparse", "urllib.parse"), MovedAttribute("urlparse", "urlparse", "urllib.parse"), MovedAttribute("urlsplit", "urlparse", "urllib.parse"), MovedAttribute("urlunparse", "urlparse", "urllib.parse"), MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), MovedAttribute("quote", "urllib", "urllib.parse"), MovedAttribute("quote_plus", "urllib", "urllib.parse"), MovedAttribute("unquote", "urllib", "urllib.parse"), MovedAttribute("unquote_plus", "urllib", "urllib.parse"), MovedAttribute("urlencode", "urllib", "urllib.parse"), MovedAttribute("splitquery", "urllib", "urllib.parse"), MovedAttribute("splittag", "urllib", "urllib.parse"), MovedAttribute("splituser", "urllib", "urllib.parse"), MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), MovedAttribute("uses_params", "urlparse", "urllib.parse"), MovedAttribute("uses_query", "urlparse", "urllib.parse"), MovedAttribute("uses_relative", "urlparse", "urllib.parse"), ] for attr in _urllib_parse_moved_attributes: setattr(Module_six_moves_urllib_parse, attr.name, attr) del attr Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), "moves.urllib_parse", "moves.urllib.parse") class Module_six_moves_urllib_error(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_error""" _urllib_error_moved_attributes = [ MovedAttribute("URLError", "urllib2", "urllib.error"), MovedAttribute("HTTPError", "urllib2", "urllib.error"), MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), ] for attr in _urllib_error_moved_attributes: setattr(Module_six_moves_urllib_error, attr.name, attr) del attr Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), "moves.urllib_error", "moves.urllib.error") class Module_six_moves_urllib_request(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_request""" _urllib_request_moved_attributes = [ MovedAttribute("urlopen", "urllib2", "urllib.request"), MovedAttribute("install_opener", "urllib2", "urllib.request"), MovedAttribute("build_opener", "urllib2", "urllib.request"), MovedAttribute("pathname2url", "urllib", "urllib.request"), MovedAttribute("url2pathname", "urllib", "urllib.request"), MovedAttribute("getproxies", "urllib", "urllib.request"), MovedAttribute("Request", "urllib2", "urllib.request"), MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), MovedAttribute("BaseHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), MovedAttribute("FileHandler", "urllib2", "urllib.request"), MovedAttribute("FTPHandler", "urllib2", "urllib.request"), MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), MovedAttribute("urlretrieve", "urllib", "urllib.request"), MovedAttribute("urlcleanup", "urllib", "urllib.request"), MovedAttribute("URLopener", "urllib", "urllib.request"), MovedAttribute("FancyURLopener", "urllib", "urllib.request"), MovedAttribute("proxy_bypass", "urllib", "urllib.request"), ] for attr in _urllib_request_moved_attributes: setattr(Module_six_moves_urllib_request, attr.name, attr) del attr Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), "moves.urllib_request", "moves.urllib.request") class Module_six_moves_urllib_response(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_response""" _urllib_response_moved_attributes = [ MovedAttribute("addbase", "urllib", "urllib.response"), MovedAttribute("addclosehook", "urllib", "urllib.response"), MovedAttribute("addinfo", "urllib", "urllib.response"), MovedAttribute("addinfourl", "urllib", "urllib.response"), ] for attr in _urllib_response_moved_attributes: setattr(Module_six_moves_urllib_response, attr.name, attr) del attr Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), "moves.urllib_response", "moves.urllib.response") class Module_six_moves_urllib_robotparser(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_robotparser""" _urllib_robotparser_moved_attributes = [ MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), ] for attr in _urllib_robotparser_moved_attributes: setattr(Module_six_moves_urllib_robotparser, attr.name, attr) del attr Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), "moves.urllib_robotparser", "moves.urllib.robotparser") class Module_six_moves_urllib(types.ModuleType): """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" __path__ = [] # mark as package parse = _importer._get_module("moves.urllib_parse") error = _importer._get_module("moves.urllib_error") request = _importer._get_module("moves.urllib_request") response = _importer._get_module("moves.urllib_response") robotparser = _importer._get_module("moves.urllib_robotparser") def __dir__(self): return ['parse', 'error', 'request', 'response', 'robotparser'] _importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), "moves.urllib") def add_move(move): """Add an item to six.moves.""" setattr(_MovedItems, move.name, move) def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,)) if PY3: _meth_func = "__func__" _meth_self = "__self__" _func_closure = "__closure__" _func_code = "__code__" _func_defaults = "__defaults__" _func_globals = "__globals__" else: _meth_func = "im_func" _meth_self = "im_self" _func_closure = "func_closure" _func_code = "func_code" _func_defaults = "func_defaults" _func_globals = "func_globals" try: advance_iterator = next except NameError: def advance_iterator(it): return it.next() next = advance_iterator try: callable = callable except NameError: def callable(obj): return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) if PY3: def get_unbound_function(unbound): return unbound create_bound_method = types.MethodType Iterator = object else: def get_unbound_function(unbound): return unbound.im_func def create_bound_method(func, obj): return types.MethodType(func, obj, obj.__class__) class Iterator(object): def next(self): return type(self).__next__(self) callable = callable _add_doc(get_unbound_function, """Get the function out of a possibly unbound function""") get_method_function = operator.attrgetter(_meth_func) get_method_self = operator.attrgetter(_meth_self) get_function_closure = operator.attrgetter(_func_closure) get_function_code = operator.attrgetter(_func_code) get_function_defaults = operator.attrgetter(_func_defaults) get_function_globals = operator.attrgetter(_func_globals) if PY3: def iterkeys(d, **kw): return iter(d.keys(**kw)) def itervalues(d, **kw): return iter(d.values(**kw)) def iteritems(d, **kw): return iter(d.items(**kw)) def iterlists(d, **kw): return iter(d.lists(**kw)) viewkeys = operator.methodcaller("keys") viewvalues = operator.methodcaller("values") viewitems = operator.methodcaller("items") else: def iterkeys(d, **kw): return iter(d.iterkeys(**kw)) def itervalues(d, **kw): return iter(d.itervalues(**kw)) def iteritems(d, **kw): return iter(d.iteritems(**kw)) def iterlists(d, **kw): return iter(d.iterlists(**kw)) viewkeys = operator.methodcaller("viewkeys") viewvalues = operator.methodcaller("viewvalues") viewitems = operator.methodcaller("viewitems") _add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") _add_doc(itervalues, "Return an iterator over the values of a dictionary.") _add_doc(iteritems, "Return an iterator over the (key, value) pairs of a dictionary.") _add_doc(iterlists, "Return an iterator over the (key, [values]) pairs of a dictionary.") if PY3: def b(s): return s.encode("latin-1") def u(s): return s unichr = chr if sys.version_info[1] <= 1: def int2byte(i): return bytes((i,)) else: # This is about 2x faster than the implementation above on 3.2+ int2byte = operator.methodcaller("to_bytes", 1, "big") byte2int = operator.itemgetter(0) indexbytes = operator.getitem iterbytes = iter import io StringIO = io.StringIO BytesIO = io.BytesIO else: def b(s): return s # Workaround for standalone backslash def u(s): return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") unichr = unichr int2byte = chr def byte2int(bs): return ord(bs[0]) def indexbytes(buf, i): return ord(buf[i]) iterbytes = functools.partial(itertools.imap, ord) import StringIO StringIO = BytesIO = StringIO.StringIO _add_doc(b, """Byte literal""") _add_doc(u, """Text literal""") if PY3: exec_ = getattr(moves.builtins, "exec") def reraise(tp, value, tb=None): if value is None: value = tp() if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value else: def exec_(_code_, _globs_=None, _locs_=None): """Execute code in a namespace.""" if _globs_ is None: frame = sys._getframe(1) _globs_ = frame.f_globals if _locs_ is None: _locs_ = frame.f_locals del frame elif _locs_ is None: _locs_ = _globs_ exec ("""exec _code_ in _globs_, _locs_""") exec_("""def reraise(tp, value, tb=None): raise tp, value, tb """) if sys.version_info > (3, 2): exec_("""def raise_from(value, from_value): raise value from from_value """) else: def raise_from(value, from_value): raise value print_ = getattr(moves.builtins, "print", None) if print_ is None: def print_(*args, **kwargs): """The new-style print function for Python 2.4 and 2.5.""" fp = kwargs.pop("file", sys.stdout) if fp is None: return def write(data): if not isinstance(data, basestring): data = str(data) # If the file has an encoding, encode unicode with it. if (isinstance(fp, file) and isinstance(data, unicode) and fp.encoding is not None): errors = getattr(fp, "errors", None) if errors is None: errors = "strict" data = data.encode(fp.encoding, errors) fp.write(data) want_unicode = False sep = kwargs.pop("sep", None) if sep is not None: if isinstance(sep, unicode): want_unicode = True elif not isinstance(sep, str): raise TypeError("sep must be None or a string") end = kwargs.pop("end", None) if end is not None: if isinstance(end, unicode): want_unicode = True elif not isinstance(end, str): raise TypeError("end must be None or a string") if kwargs: raise TypeError("invalid keyword arguments to print()") if not want_unicode: for arg in args: if isinstance(arg, unicode): want_unicode = True break if want_unicode: newline = unicode("\n") space = unicode(" ") else: newline = "\n" space = " " if sep is None: sep = space if end is None: end = newline for i, arg in enumerate(args): if i: write(sep) write(arg) write(end) _add_doc(reraise, """Reraise an exception.""") if sys.version_info[0:2] < (3, 4): def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES): def wrapper(f): f = functools.wraps(wrapped)(f) f.__wrapped__ = wrapped return f return wrapper else: wraps = functools.wraps def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(meta): def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, 'temporary_class', (), {}) def add_metaclass(metaclass): """Class decorator for creating a class with a metaclass.""" def wrapper(cls): orig_vars = cls.__dict__.copy() slots = orig_vars.get('__slots__') if slots is not None: if isinstance(slots, str): slots = [slots] for slots_var in slots: orig_vars.pop(slots_var) orig_vars.pop('__dict__', None) orig_vars.pop('__weakref__', None) return metaclass(cls.__name__, cls.__bases__, orig_vars) return wrapper # Complete the moves implementation. # This code is at the end of this module to speed up module loading. # Turn this module into a package. __path__ = [] # required for PEP 302 and PEP 451 __package__ = __name__ # see PEP 366 @ReservedAssignment if globals().get("__spec__") is not None: __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable # Remove other six meta path importers, since they cause problems. This can # happen if six is removed from sys.modules and then reloaded. (Setuptools does # this for some reason.) if sys.meta_path: for i, importer in enumerate(sys.meta_path): # Here's some real nastiness: Another "instance" of the six module might # be floating around. Therefore, we can't use isinstance() to check for # the six meta path importer, since the other six instance will have # inserted an importer with different class. if (type(importer).__name__ == "_SixMetaPathImporter" and importer.name == __name__): del sys.meta_path[i] break del i, importer # Finally, add the importer to the meta path import hook. sys.meta_path.append(_importer) python-casacore-2.2.1/casacore/tables/000077500000000000000000000000001320311315100176335ustar00rootroot00000000000000python-casacore-2.2.1/casacore/tables/__init__.py000077500000000000000000000054301320311315100217510ustar00rootroot00000000000000# __init__.py: Top level .py file for python table interface # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: __init__.py,v 1.6 2006/11/06 01:54:21 gvandiep Exp $ """Python interface to the Casacore tables module. A `casacore table <../../casacore/doc/html/group__Tables__module.html>`_ is similar to a relational data base table with the extension that table cells can contain n-dimensional arrays. It has a rich SQL-like query language (`TaQL <../../doc/199.html>`_). A table consists of numbered rows and named columns. A column can hold scalar values or arrays of any dimensionality and shape. Furthermore the table and each column can hold a set of keywords (e.g. to define the units). It is nestable, thus the value of a keyword can be a keyword set in itself. The `tables` module consists of a few classes: :class:`table` main module to open, create, access, and query tables :class:`tablecolumn` access the contents of a column in an easier way :class:`tablerow` access the contents of table rows or parts of it :class:`tableiter` iterate through a table based on the contents of one or more columns :class:`tableindex` build and use an index on one or more table columns submodule `tableutil <#table-utility-functions>`_ table utility functions (e.g. to create a table description) submodule `msutil <#measurementset-utility-functions>`_ MeasuementSet utility functions (e.g. to concat MSs) """ from .msutil import * from .table import table from .table import default_ms from .table import default_ms_subtable from .table import tablecommand from .table import taql from .tablecolumn import tablecolumn from .tableindex import tableindex from .tableiter import tableiter from .tablerow import tablerow from .tableutil import * python-casacore-2.2.1/casacore/tables/msutil.py000066400000000000000000000423061320311315100215270ustar00rootroot00000000000000# msutil.py: Utility MeasurementSet functions # Copyright (C) 2011 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # import numpy as np from casacore import six from casacore.tables.table import table, taql, _required_ms_desc from casacore.tables.tableutil import makescacoldesc, makearrcoldesc, \ makecoldesc, maketabdesc def required_ms_desc(table=None): """ Obtain the required table description for a given table. If "" or "MAIN", the description for a MeasurementSet is returned. Otherwise, a the description for a MeasurementSet subtable is returned. """ # Default to MAIN table if table is None: table = "" return _required_ms_desc(table) def addImagingColumns(msname, ack=True): """ Add the columns to an MS needed for the casa imager. It adds the columns MODEL_DATA, CORRECTED_DATA, and IMAGING_WEIGHT. It also sets the CHANNEL_SELECTION keyword needed for the older casa imagers. A column is not added if already existing. """ # numpy is needed import numpy as np # Open the MS t = table(msname, readonly=False, ack=False) cnames = t.colnames() # Get the description of the DATA column. try: cdesc = t.getcoldesc('DATA') except: raise ValueError('Column DATA does not exist') # Determine if the DATA storage specification is tiled. hasTiled = False try: dminfo = t.getdminfo("DATA") if dminfo['TYPE'][:5] == 'Tiled': hasTiled = True except: hasTiled = False # Use TiledShapeStMan if needed. if not hasTiled: dminfo = {'TYPE': 'TiledShapeStMan', 'SPEC': {'DEFAULTTILESHAPE': [4, 32, 128]}} # Add the columns(if not existing). Use the description of the DATA column. if 'MODEL_DATA' in cnames: six.print_("Column MODEL_DATA not added; it already exists") else: dminfo['NAME'] = 'modeldata' cdesc['comment'] = 'The model data column' t.addcols(maketabdesc(makecoldesc('MODEL_DATA', cdesc)), dminfo) if ack: six.print_("added column MODEL_DATA") if 'CORRECTED_DATA' in cnames: six.print_("Column CORRECTED_DATA not added; it already exists") else: dminfo['NAME'] = 'correcteddata' cdesc['comment'] = 'The corrected data column' t.addcols(maketabdesc(makecoldesc('CORRECTED_DATA', cdesc)), dminfo) if ack: six.print_("'added column CORRECTED_DATA") if 'IMAGING_WEIGHT' in cnames: six.print_("Column IMAGING_WEIGHT not added; it already exists") else: # Add IMAGING_WEIGHT which is 1-dim and has type float. # It needs a shape, otherwise the CASA imager complains. shp = [] if 'shape' in cdesc: shp = cdesc['shape'] if len(shp) > 0: shp = [shp[0]] # use nchan from shape else: shp = [t.getcell('DATA', 0).shape[0]] # use nchan from actual data cd = makearrcoldesc('IMAGING_WEIGHT', 0, ndim=1, shape=shp, valuetype='float') dminfo = {'TYPE': 'TiledShapeStMan', 'SPEC': {'DEFAULTTILESHAPE': [32, 128]}} dminfo['NAME'] = 'imagingweight' t.addcols(maketabdesc(cd), dminfo) if ack: six.print_("added column IMAGING_WEIGHT") # Add or overwrite keyword CHANNEL_SELECTION. if 'CHANNEL_SELECTION' in t.colkeywordnames('MODEL_DATA'): t.removecolkeyword('MODEL_DATA', 'CHANNEL_SELECTION') # Define the CHANNEL_SELECTION keyword containing the channels of # all spectral windows. tspw = table(t.getkeyword('SPECTRAL_WINDOW'), ack=False) nchans = tspw.getcol('NUM_CHAN') chans = [[0, nch] for nch in nchans] t.putcolkeyword('MODEL_DATA', 'CHANNEL_SELECTION', np.int32(chans)) if ack: six.print_("defined keyword CHANNEL_SELECTION in column MODEL_DATA") # Flush the table to make sure it is written. t.flush() def removeImagingColumns(msname): # Open the MS t = table(msname, readonly=False, ack=False) # Remove if the column exists. cnames = t.colnames() removeNames = [] for col in ['MODEL_DATA', 'CORRECTED_DATA', 'IMAGING_WEIGHT']: if col in cnames: removeNames.append(col) if len(removeNames) > 0: t.removecols(removeNames) t.flush() def addDerivedMSCal(msname): """ Add the derived columns like HA to an MS or CalTable. It adds the columns HA, HA1, HA2, PA1, PA2, LAST, LAST1, LAST2, AZEL1, AZEL2, and UVW_J2000. They are all bound to the DerivedMSCal virtual data manager. It fails if one of the columns already exists. """ # Open the MS t = table(msname, readonly=False, ack=False) colnames = t.colnames() # Check that the columns needed by DerivedMSCal are present. # Note that ANTENNA2 and FEED2 are not required. for col in ["TIME", "ANTENNA1", "FIELD_ID", "FEED1"]: if col not in colnames: raise ValueError("Columns " + colnames + " should be present in table " + msname) scols1 = ['HA', 'HA1', 'HA2', 'PA1', 'PA2'] scols2 = ['LAST', 'LAST1', 'LAST2'] acols1 = ['AZEL1', 'AZEL2'] acols2 = ['UVW_J2000'] descs = [] # Define the columns and their units. for col in scols1: descs.append(makescacoldesc(col, 0., keywords={"QuantumUnits": ["rad"]})) for col in scols2: descs.append(makescacoldesc(col, 0., keywords={"QuantumUnits": ["d"]})) for col in acols1: descs.append(makearrcoldesc(col, 0., keywords={"QuantumUnits": ["rad", "rad"]})) for col in acols2: descs.append(makearrcoldesc(col, 0., keywords={"QuantumUnits": ["m", "m", "m"], "MEASINFO": {"Ref": "J2000", "type": "uvw"}})) # Add all columns using DerivedMSCal as data manager. dminfo = {"TYPE": "DerivedMSCal", "NAME": "", "SPEC": {}} t.addcols(maketabdesc(descs), dminfo) # Flush the table to make sure it is written. t.flush() def removeDerivedMSCal(msname): """ Remove the derived columns like HA from an MS or CalTable. It removes the columns using the data manager DerivedMSCal. Such columns are HA, HA1, HA2, PA1, PA2, LAST, LAST1, LAST2, AZEL1, AZEL2, and UVW_J2000. It fails if one of the columns already exists. """ # Open the MS t = table(msname, readonly=False, ack=False) # Remove the columns stored as DerivedMSCal. dmi = t.getdminfo() for x in dmi.values(): if x['TYPE'] == 'DerivedMSCal': t.removecols(x['COLUMNS']) t.flush() def msconcat(names, newname, concatTime=False): """Virtually concatenate multiple MeasurementSets. Multiple MeasurementSets are concatenated into a single MeasurementSet. The concatenation is done in an entirely or almost entirely virtual way, so hardly any data are copied. It makes the command very fast and hardly any extra disk space is needed. The MSs can be concatenated in time or frequency (spectral windows). If concatenated in time, no indices need to be updated and the concatenation is done in a single step. If spectral windows are concatenated, the data-description-ids and spectral-window-ids in the resulting MS and its subtables are updated to make them unique. The spectral concatenation is done in two steps and results in two MSs: 1. The input MSs are virtually concatenated resulting in the MeasurementSet `_CONCAT`. 2. The MeasurementSet is created. It references all columns in `_CONCAT` with the exception of the DATA_DESC_ID column. This column is copied and updated to make the ids correct. Furthermore the MS contains a copy of all subtables (with the exception of SORTED_TABLE), where the DATA_DESCRIPTION and SPECTRAL_WINDOW subtables are the concatenation of those subtables in the input MSs. The ids in the resulting subtables are updated. The FEED, FREQ_OFFSET, SOURCE, and SYSCAL subtables also have a SPECTRAL_WINDOW_ID column. Currently these subtables are not concatenated nor are their ids updated. `names` A sequence containing the names of the MeasurementSets to concatenate. `newname` The name of the resulting MeasurementSet. A MeasurementSet with this name followed by `_CONCAT` will also be created (and must be kept). `concatTime` False means that the spectral windows ids will be adjusted as explained above. """ if len(names) == 0: raise ValueError('No input MSs given') # Concatenation in time is straightforward. if concatTime: t = table(names[0]) if 'SYSCAL' in t.fieldnames(): tn = table(names, concatsubtables='SYSCAL') else: tn = table(names) t.close() tn.rename(newname) return # First concatenate the given tables as another table. # The SPECTRAL_WINDOW and DATA_DESCRIPTION subtables are concatenated # and changed later. # Those subtables cannot be concatenated here, because the deep copy of # them fails due to the rename of the main table. tn = table(names) tdesc = tn.getdesc() tn.rename(newname + '_CONCAT') tn.flush() # Now create a table where all columns forward to the concatenated table, # but create a stored column for the data description id, because it has # to be changed. # The new column is filled at the end. tnew = table(newname, tdesc, nrow=tn.nrows(), dminfo={ '1': {'TYPE': 'ForwardColumnEngine', 'NAME': 'ForwardData', 'COLUMNS': tn.colnames(), 'SPEC': {'FORWARDTABLE': tn.name()}}}) # Remove the DATA_DESC_ID column and recreate it in a stored way. tnew.removecols('DATA_DESC_ID') tnew.addcols(makecoldesc('DATA_DESC_ID', tdesc['DATA_DESC_ID']), dminfo={'TYPE': 'IncrementalStMan', 'NAME': 'DDID', 'SPEC': {}}) # Copy the table keywords. keywords = tn.getkeywords() tnew.putkeywords(keywords) # Copy all column keywords. for col in tn.colnames(): tnew.putcolkeywords(col, tn.getcolkeywords(col)) # Make a deep copy of all subtables (except SORTED_TABLE). for key in keywords: if key != 'SORTED_TABLE': val = keywords[key] if isinstance(val, str): tsub = table(val, ack=False) tsubn = tsub.copy(newname + '/' + key, deep=True) tnew.putkeyword(key, tsubn) tnew.flush() # Now we have to take care that the subbands are numbered correctly. # The DATA_DESCRIPTION and SPECTRAL_WINDOW subtables are concatenated. # The ddid in the main table and spwid in DD subtable have to be updated. tnewdd = table(tnew.getkeyword('DATA_DESCRIPTION'), readonly=False, ack=False) tnewspw = table(tnew.getkeyword('SPECTRAL_WINDOW'), readonly=False, ack=False) nrdd = 0 nrspw = 0 nrmain = 0 for name in names: t = table(name, ack=False) tdd = table(t.getkeyword('DATA_DESCRIPTION'), ack=False) tspw = table(t.getkeyword('SPECTRAL_WINDOW'), ack=False) # The first table already has its subtable copied. # Append the subtables of the other ones. if nrdd > 0: tnewdd.addrows(tdd.nrows()) for i in range(tdd.nrows()): tnewdd[nrdd + i] = tdd[i] # copy row i tnewspw.addrows(tspw.nrows()) for i in range(tspw.nrows()): tnewspw[nrspw + i] = tspw[i] tnewdd.putcol('SPECTRAL_WINDOW_ID', tdd.getcol('SPECTRAL_WINDOW_ID') + nrspw, nrdd, tdd.nrows()) tnew.putcol('DATA_DESC_ID', t.getcol('DATA_DESC_ID') + nrdd, nrmain, t.nrows()) nrdd += tdd.nrows() nrspw += tspw.nrows() nrmain += t.nrows() # Overwrite keyword CHANNEL_SELECTION. if 'MODEL_DATA' in tnew.colnames(): if 'CHANNEL_SELECTION' in tnew.colkeywordnames('MODEL_DATA'): tnew.removecolkeyword('MODEL_DATA', 'CHANNEL_SELECTION') # Define the CHANNEL_SELECTION keyword containing the channels of # all spectral windows. tspw = table(tnew.getkeyword('SPECTRAL_WINDOW'), ack=False) nchans = tspw.getcol('NUM_CHAN') chans = [[0, nch] for nch in nchans] tnew.putcolkeyword('MODEL_DATA', 'CHANNEL_SELECTION', np.int32(chans)) # Future work: # If SOURCE subtables have to concatenated, the FIELD and DOPPLER # have to be dealt with as well. # The FEED table can be concatenated; the FEED_ID can stay the same, # but spwid has to be updated. # The FREQ_OFFSET table is stand-alone, thus can simply be concatenated # and have spwid updated. # The SYSCAL table can be very large, so it might be better to virtually # concatenate it instead of making a copy (just like the main table). # Flush the table and subtables. tnew.flush(True) def msregularize(msname, newname): """ Regularize an MS The output MS will be such that it has the same number of baselines for each time stamp. Where needed fully flagged rows are added. Possibly missing rows are written into a separate MS -add. It is concatenated with the original MS and sorted in order of TIME, DATADESC_ID, ANTENNA1,ANTENNA2 to form a new regular MS. Note that the new MS references the input MS (it does not copy the data). It means that changes made in the new MS are also made in the input MS. If no rows were missing, the new MS is still created referencing the input MS. """ # Find out all baselines. t = table(msname) t1 = t.sort('unique ANTENNA1,ANTENNA2') nadded = 0 # Now iterate in time,band over the MS. for tsub in t.iter(['TIME', 'DATA_DESC_ID']): nmissing = t1.nrows() - tsub.nrows() if nmissing < 0: raise ValueError("A time/band chunk has too many rows") if nmissing > 0: # Rows needs to be added for the missing baselines. ant1 = str(t1.getcol('ANTENNA1')).replace(' ', ',') ant2 = str(t1.getcol('ANTENNA2')).replace(' ', ',') ant1 = tsub.getcol('ANTENNA1') ant2 = tsub.getcol('ANTENNA2') t2 = taql('select from $t1 where !any(ANTENNA1 == $ant1 &&' + ' ANTENNA2 == $ant2)') six.print_(nmissing, t1.nrows(), tsub.nrows(), t2.nrows()) if t2.nrows() != nmissing: raise ValueError("A time/band chunk behaves strangely") # If nothing added yet, create a new table. # (which has to be reopened for read/write). # Otherwise append to that new table. if nadded == 0: tnew = t2.copy(newname + "_add", deep=True) tnew = table(newname + "_add", readonly=False) else: t2.copyrows(tnew) # Set the correct time and band in the new rows. tnew.putcell('TIME', range(nadded, nadded + nmissing), tsub.getcell('TIME', 0)) tnew.putcell('DATA_DESC_ID', range(nadded, nadded + nmissing), tsub.getcell('DATA_DESC_ID', 0)) nadded += nmissing # Combine the existing table and new table. if nadded > 0: # First initialize data and flags in the added rows. taql('update $tnew set DATA=0+0i') taql('update $tnew set FLAG=True') tcomb = table([t, tnew]) tcomb.rename(newname + '_adds') tcombs = tcomb.sort('TIME,DATA_DESC_ID,ANTENNA1,ANTENNA2') else: tcombs = t.query(offset=0) tcombs.rename(newname) six.print_(newname, 'has been created; it references the original MS') if nadded > 0: six.print_(' and', newname + '_adds', 'containing', nadded, 'new rows') else: six.print_(' no rows needed to be added') python-casacore-2.2.1/casacore/tables/table.py000077500000000000000000002276271320311315100213170ustar00rootroot00000000000000# table.py: Python table functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: table.py,v 1.13 2006/11/10 01:18:53 gvandiep Exp $ """Access to Casacore tables. The :class:`table` class is the main class to access a table. Its constructor can open or create a table. Several utility functions exist. Important ones are: :func:`taql` (or its synonym `tablecommand`) executes a TaQL query command and returns a :class:`table` object. :func:`tablefromascii` creates a table from an ASCII file and returns a :class:`table` object. """ # Make interface to class TableProxy available. from ._tables import (Table, _default_ms, _default_ms_subtable, _required_ms_desc) from .tablehelper import (_add_prefix, _remove_prefix, _do_remove_prefix, _format_row) from casacore import six def default_ms(name, tabdesc=None, dminfo=None): """ Creates a default Measurement Set called name. Any Table Description elements in tabdesc will overwrite the corresponding element in a default Measurement Set Table Description (columns, hypercolumns and keywords). In practice, you probably want to specify columns such as DATA, MODEL_DATA and CORRECTED_DATA (and their associated keywords and hypercolumns) in tabdesc """ # Default to empty dictionaries if tabdesc is None: tabdesc = {} if dminfo is None: dminfo = {} # Wrap the Table object return table(_default_ms(name, tabdesc, dminfo), _oper=3) def default_ms_subtable(subtable, name=None, tabdesc=None, dminfo=None): """ Creates a default Measurement Set subtable. Any Table Description elements in tabdesc will overwrite the corresponding element in a default Measurement Set Table Description (columns, hypercolumns and keywords). if name is given, it will be treated as a path that the table should be created in. Set to subtable if None if subtable is "" or "MAIN" a standard MeasurementSet with subtables will be created. """ if name is None: name = subtable # Default to empty dictionaries if tabdesc is None: tabdesc = {} if dminfo is None: dminfo = {} # Wrap the Table object return table(_default_ms_subtable(subtable, name, tabdesc, dminfo), _oper=3) # Execute a TaQL command on a table. def taql(command, style='Python', tables=[], globals={}, locals={}): """Execute a TaQL command and return a table object. A `TaQL <../../doc/199.html>`_ command is an SQL-like command to do a selection of rows and/or columns in a table. The default style used in a TaQL command is python, which means 0-based indexing, C-ordered arrays, and non-inclusive end in ranges. It is possible to use python variables directly in the command using `$var` where `var` is the name of the variable to use. For example:: t = table('3c343.MS') value = 5.1 t1 = taql('select from $t where COL > $value') In this example the table `$t` is replaced by a sequence number (like `$1`) and `$value` by its value 5.1. The table object of `t` will be appended to a copy of the `tables` argument such that the sequence number inserted matches the table object in the list. The more advanced user can already use `$n` in the query string and supply the associated table object in the `tables` argument (where `n` represents the (n-1)th `tables` element). The :func:`query` command makes use of this feature. The arguments `globals` and `locals` can be used to pass in a dict containing the possible variables used in the TaQL command. They can be obtained with the python functions locals() and globals(). If `locals` is empty, the local variables in the calling function will be used, so normally one does not need to use these arguments. """ # Substitute possible tables given as $name. cmd = command # Copy the tables argument and make sure it is a list tabs = [] for tab in tables: tabs += [tab] try: import casacore.util if len(locals) == 0: # local variables in caller are 3 levels up from getlocals locals = casacore.util.getlocals(3) cmd = casacore.util.substitute(cmd, [(table, '', tabs)], globals, locals) except: pass if style: cmd = 'using style ' + style + ' ' + cmd tab = table(cmd, tabs, _oper=2) result = tab._getcalcresult() # If result is empty, it was a normal TaQL command resulting in a table. # Otherwise it is a record containing calc values. if len(result) == 0: return tab return result['values'] # alias tablecommand = taql class table(Table): """The Python interface to Casacore tables. One can open or create tables, get or put data in them, make selections, get meta information (like storage managers used), etc. It is possible to lock/unlock a table for concurrent access. A table consists of numbered rows and named columns. A column can hold scalar values or arrays of any dimensionality and shape. Furthermore the table and each column can hold a possibly nested keyword set (e.g. to define the units). The classes :class:`tablecolumn`, :class:`tableiter`, :class:`tableindex`, and :class:`tablerow` tablecolumn can be used for easier access to tables. Module tableutil contains some useful utility functions, for instance :func:`tablefromascii` to create a table from an ASCII file. Several functions accept or return arrays for which numpy arrays are used. One dimensional arrays can also be passed as sequences (e.g., a list). A scalar value can also be passed to functions expecting an array and results in a 1-dim array of length 1. Scalar arguments can be passed as normal python scalars, but also as numpy scalars (which have a special data type). If needed and if possible, data type conversion is done automatically. A `table` object contains a :class:`tablerow` object which contains all columns. Similar to `tablerow` the `table` object can be indexed in the standard python way to get (or put) values in one or more rows. For example:: t = table('~/3c343.MS') print t[0] The `table` class supports the context manager idiom (__enter__ and __exit__). When used in a `with` statement, the table will be flushed and closed automatically, which is handy when writing a table. For example:: with table('my.ms') as t: t.putcell ('SPECTRAL_WINDOW_ID', 0, 0) Usually a table is kept on disk, but it can also reside in memory. Furthermore, results of sort and selection are kept as so-called reference tables which are kept in memory (but can be made persistent). `table('tablename', tabledesc)` creates a new table using the given table description which can be obtained from an existing table (using table.getdesc) or created (using tableutil.maketabdesc). If `memorytable=True`, the table is created in memory. `table('tablename', readonly=False)` | opens an existing table for read/write. Default is for readonly. | In general it is a bad idea to open a subtable using a path like 'my.ms/ANTENNA', because it will fail if 'my.ms' is a selection instead of a plain table. Therefore a double colon can be used like 'my.ms::ANTENNA' making the table system handle it in a correct way. `table(['table1','table2',...])` opens a virtual table as the concatenation of the given tables. The tables have to have the same columns. `table([tableobject1,tableobject2,...])` opens a virtual table as the concatenation of the given table objects. The tables have to have the same columns. The following arguments can be used. `tablename` | name of the table to be opened or created. As in most UNIX shells a table name can contain environment variables and a tilde with optional user name. | This argument can be a sequence of names in which case they are opened as a (virtual) concatenation of tables. | It can also be a sequence of table objects to be concatenated. `tabledesc` description of table to be created. If given as a dict (which should be created by :func:`maketabdesc`, the table is created. Otherwise it should exist and is opened. `nrow` initial number of rows in table to be created (default 0). `readonly = True/False` tell if a table has to be opened readonly (default) or read/write. `lockoptions` see below `ack=False` prohibit the printing of a message telling if the table was opened or created successfully. `dminfo` a dict (as returned by :func:`getdminfo`) giving specific data manager info for one or more columns. In this way expert users can tell how data are stored (or use virtual data managers). `endian` | endianness of the data in table to be created | 'little' = as little endian | 'big' = as big endian | 'local' = use the endianness of the machine being used | 'aipsrc' = use a defined in an .aipsrc file (defaults to local) `memorytable=True` create table in memory instead of on disk. `concatsubtables` if tables are concatenated, it should contain a sequence of the names of subtables to be concatenated as well (default none). Non-mentioned subtables are considered to be identical in each table, so only the subtable of the first table is used as subtable for the concatenated table. Locking/unlocking to share a table in a concurrent environment is controlled by the lockoptions argument. `auto` let the system take care of locking. It locks when needed, but unlocking is usually not done automatically. `autonoread` as `auto`, but no read locking is needed. This must be used with care, because it means that reading can be done while the table object is not synchronized with the table file (as is normally done when a lock is acquired). The method :func:`resync` can be used to explicitly synchronize the table object with the file. `user` the user takes care by explicit calls to lock and unlock `usernoread` as `user` and the no readlocking behaviour of `autonoread`. `permanent` use a permanent write lock; the constructor fails if the lock cannot be acquired because the table is already in use in another process `permanentwait` as above, but wait until the lock is acquired. `default` this is the default option. If the given table is already open, the locking option in use is not changed. Otherwise it reverts to `auto`. If auto locking is used, it is possible to give a record containing the fields option, interval, and/or maxwait (see :func:`lockoptions` for their meaning). In this way advanced users can have full control over the locking process. In practice this is hardly ever needed. For example:: t = table('3c343.ms') # open table readonly t = table('3c343.ms', readonly=False) # open table read/write t1= table('new.tab', t.getdesc()) # create table t = table([t1,t2,t3,t4]) # concatenate 4 tables """ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True, lockoptions='default', ack=True, dminfo={}, endian='aipsrc', memorytable=False, concatsubtables=[], _columnnames=[], _datatypes=[], _oper=0, _delete=False): """Open or create a table.""" if _oper == 1: # This is the readascii constructor. tabname = _remove_prefix(tablename) Table.__init__(self, tabname, tabledesc, nrow, readonly, lockoptions, ack, dminfo, endian, memorytable, _columnnames, _datatypes) elif _oper == 2: # This is the query or calc constructor. Table.__init__(self, tablename, tabledesc) if len(self._getcalcresult()) != 0: # Do not make row object for a calc result return elif _oper == 3: # This is the constructor taking a Table (used by copy). Table.__init__(self, tablename) else: # This is the constructor for a normal table open. # It can be done in several forms: # - open single existing table (PlainTable) # - open multiple existing tables (ConcatTable) # - create a new table (PlainTable or MemoryTable) # - concatenate open tables (ConcatTable) tabname = _remove_prefix(tablename) lockopt = lockoptions if isinstance(lockoptions, str): lockopt = {'option': lockoptions} if isinstance(tabledesc, dict): # Create a new table. memtype = 'plain' if (memorytable): memtype = 'memory' Table.__init__(self, tabname, lockopt, endian, memtype, nrow, tabledesc, dminfo) if ack: six.print_('Successful creation of', lockopt['option'] + '-locked table', tabname + ':', self.ncols(), 'columns,', self.nrows(), 'rows') else: # Deal with existing tables. if not tabname: raise ValueError("No tables or names given") # Open an existing table opt = 1 typstr = 'readonly' if not readonly: typstr = 'read/write' opt = 5 if _delete: opt = 6 if isinstance(tabname, str): Table.__init__(self, tabname, lockopt, opt) if ack: six.print_('Successful', typstr, 'open of', lockopt['option'] + '-locked table', tabname + ':', self.ncols(), 'columns,', self.nrows(), 'rows') elif isinstance(tabname[0], str): # Concatenate and open named tables. Table.__init__(self, tabname, concatsubtables, lockopt, opt) if ack: six.print_('Successful', typstr, 'open of', lockopt['option'] + '-locked concatenated tables', tabname, ':', self.ncols(), 'columns,', self.nrows(), 'rows') else: # Concatenate already open tables. Table.__init__(self, tabname, concatsubtables, 0, 0, 0) if ack: six.print_('Successful virtual concatenation of', len(tabname), 'tables:', self.ncols(), 'columns,', self.nrows(), 'rows') # Create a row object for this table. self._makerow() def __enter__(self): """Function to enter a with block.""" return self def __exit__(self, type, value, traceback): """Function to exit a with block which closes the table object.""" self.close() def _makerow(self): """Internal method to make its tablerow object.""" from .tablerow import _tablerow self._row = _tablerow(self, []) def __str__(self): """Return the table name and the basic statistics""" return _add_prefix(self.name()) + "\n%d rows" % self.nrows() + "\n" + \ "%d columns: " % len(self.colnames()) + " ".join(self.colnames()) def __len__(self): """Return the number of rows in the table.""" return self._nrows() def __getattr__(self, name): """Get the tablecolumn object or keyword value. | A tablecolumn object is returned if it names a column. | The value of a keyword is returned if it names a keyword. If the keyword is a subtable, it opens the table and returns a table object. | The values of all keywords is returned if name equals _ or keys. An AttributeError is raised if the name is column nor keyword. For example:: print t.DATA[i] # print row i of column DATA print t.MS_VERSION # print the MS version print t.keys # print values of all keywords subtab = t.FEED # open the FEED subtable """ # First try if it is a column. try: return self.col(name) except: pass # Now try if it is a keyword. try: val = self.getkeyword(name) # See if the keyword represents a subtable and try to open it. if val != _do_remove_prefix(val): try: return table(val, ack=False) except: pass return val except: pass # _ or keys means all keywords. if name == '_' or name == 'keys': return self.getkeywords() # Unknown name. raise AttributeError("table has no attribute/column/keyword " + name) def __getitem__(self, key): """Get the values from one or more rows.""" return self._row._getitem(key, self.nrows()) def __setitem__(self, key, value): """Put value into one or more rows.""" self._row._setitem(key, value, self.nrows()) def col(self, columnname): """Return a tablecolumn object for the given column. If multiple operations need to be done on a column, a :class:`tablecolumn` object is somewhat easier to use than the table object because the column name does not have to be repeated each time. It is also possible to use a column name as an attribute, It is an easier way to get a column object. For example:: tc = t.col('DATA') tc[0:10] # get first 10 rows of column DATA t.DATA[0:10] # does the same in an easier way """ from .tablecolumn import tablecolumn return tablecolumn(self, columnname) def row(self, columnnames=[], exclude=False): """Return a tablerow object which includes (or excludes) the given columns. :class:`tablerow` makes it possible to get/put values in one or more rows. """ from .tablerow import tablerow return tablerow(self, columnnames, exclude) def iter(self, columnnames, order='', sort=True): """Return a tableiter object. :class:`tableiter` lets one iterate over a table by returning in each iteration step a reference table containing equal values for the given columns. By default a sort is done on the given columns to get the correct iteration order. `order` | 'ascending' is iterate in ascending order (is the default). | 'descending' is iterate in descending order. `sort=False` do not sort (because table is already in correct order). For example, iterate by time through a measurementset table:: t = table('3c343.MS') for ts in t.iter('TIME'): print ts.nrows() """ from .tableiter import tableiter return tableiter(self, columnnames, order, sort) def index(self, columnnames, sort=True): """Return a tableindex object. :class:`tableindex` lets one get the row numbers of the rows holding given values for the columns for which the index is created. It uses an in-memory index on which a binary search is done. By default the table is sorted on the given columns to get the correct index order. For example:: t = table('3c343.MS') tinx = t.index('ANTENNA1') print tinx.rownumbers(0) # print rownrs containing ANTENNA1=0 """ from .tableindex import tableindex return tableindex(self, columnnames, sort) def flush(self, recursive=False): """Flush the table to disk. Until a flush or unlock is performed, the results of operations might not be stored on disk yet. | If `recursive=True`, all subtables are flushed as well. """ self._flush(recursive) def resync(self): """Resync the table object with the file contents. Usually concurrent access is handled by acquiring read and write locks. However, a table can be opened without the need for read locking using lock option `usernoread` or `autonoread`. in that case synchronization of the table object and actual file contents can be done manually using this method. """ self._resync() def close(self): """Flush and close the table which invalidates the table object.""" self._row = 0 self._close() def done(self): """Flush and close the table which invalidates the table object.""" self.close() def toascii(self, asciifile, headerfile='', columnnames=(), sep=' ', precision=(), usebrackets=True): """Write the table in ASCII format. It is approximately the inverse of the from-ASCII-contructor. `asciifile` The name of the resulting ASCII file. `headerfile` The name of an optional file containing the header info. If not given or if equal to argument `asciifile`, the headers are written at the beginning of the ASCII file. `columnnames` The names of the columns to be written. If not given or if the first name is empty, all columns are written. `sep` The separator to be used between values. Only the first character of a string is used. If not given or mepty, a blank is used. `precision` For each column the precision can be given. It is only used for columns containing floating point numbers. A value <=0 means using the default which is 9 for single and 18 for double precision. `usebrackets` If True, arrays and records are written enclosed in []. Multi-dimensional arrays have [] per dimension. In this way variable shaped array can be read back correctly. However, it is not supported by :func:`tablefromascii`. If False, records are not written and arrays are written linearly with the shape defined in the header as supported byI :func:`tablefromascii`. Note that columns containing records or variable shaped arrays are ignored, because they cannot be written to ASCII. It is told which columns are ignored. For example:: t = table('3c343.MS') t1 = t.query('ANTENNA1 != ANTENNA2') # do row selection t1.toascii ('3c343.txt') # write selection as ASCII """ msg = self._toascii(asciifile, headerfile, columnnames, sep, precision, usebrackets) if len(msg) > 0: six.print_(msg) def rename(self, newtablename): """Rename the table. It renames the table and, if needed, adjusts the names of its subtables. """ self._rename(newtablename) def copy(self, newtablename, deep=False, valuecopy=False, dminfo={}, endian='aipsrc', memorytable=False, copynorows=False): """Copy the table and return a table object for the copy. It copies all data in the columns and keywords. Besides the table, all its subtables are copied too. By default a shallow copy is made (usually by copying files). It means that the copy of a reference table is also a reference table. Use `deep=True` to make a deep copy which turns a reference table into a normal table. `deep=True` a deep copy of a reference table is made. `valuecopy=True` values are copied, which reorganizes normal tables and removes wasted space. It implies `deep=True`. It is slower than a normal copy. `dminfo` gives the option to specify data managers to change the way columns are stored. This is a dict as returned by method :func:`getdminfo`. `endian` specifies the endianness of the new table when a deep copy is made: | 'little' = as little endian | 'big' = as big endian | 'local' = use the endianness of the machine being used | 'aipsrc' = use as defined in an .aipsrc file (defaults to local) `memorytable=True` do not copy to disk, but to a table kept in memory. `copynorows=True` only copy the column layout and keywords, but no data. For example:: t = table('3c343.MS') t1 = t.query('ANTENNA1 != ANTENNA2') # do row selection t2 = t1.copy ('3c343.sel', True) # make deep copy t2 = t.copy ('new.tab', True, True) # reorganize storage """ t = self._copy(newtablename, memorytable, deep, valuecopy, endian, dminfo, copynorows) # copy returns a Table object, so turn that into table. return table(t, _oper=3) def copyrows(self, outtable, startrowin=0, startrowout=-1, nrow=-1): """Copy the contents of rows from this table to outtable. The contents of the columns with matching names are copied. The other arguments can be used to specify where to start copying. By default the entire input table is appended to the output table. Rows are added to the output table if needed. `startrowin` Row where to start in the input table. `startrowout` Row where to start in the output table, | -1 means write at the end of the output table. `nrow` Number of rows to copy | -1 means from startrowin till the end of the input table The following example appends row to the table itself, thus doubles the number of rows:: t:=table('test.ms',readonly=F) t.copyrows(t) """ self._copyrows(outtable, startrowin, startrowout, nrow) def iswritable(self): """Return if the table is writable.""" return self._iswritable() def endianformat(self): """Return the endian format ('little' or 'big') in which the table is written.""" return self._endianformat() def lock(self, write=True, nattempts=0): """Acquire a read or write lock on a table. `write=False` means a read lock, otherwise a write lock. | nattempts defines the nr of attempts (one attempt per second) to do before giving up. The default 0 means unlimited. An exception is thrown if no lock could be acquired. If the table has already been locked appropriately, nothing will be done. Thus locks do NOT nest. """ self._lock(write, nattempts) def unlock(self): """Unlock the table. Flush the table data and release a read or write lock on the table acquired by lock(). Nothing will be done if the table is not locked. """ self._unlock() def haslock(self, write=True): """Test if the table is read or write locked.""" return self._haslock(write) def lockoptions(self): """Return the lockoptions. They are returned as a dict with fields: 'option' the locking mode (user, usernoread, auto, autonoread, permanent, permanentwait). `interval` In case of AutoLocking the inspection interval defines how often the table system checks if another process needs a lock on the table. `maxwait` the maximum time to wait when acquiring a lock in AutoLocking mode. """ return self._lockoptions() def datachanged(self): """Tell if data in the table have changed since the last time called.""" return self._datachanged() def ismultiused(self, checksubtables=False): """Tell if the table is used in other processes. `checksubtables=True` means it will also check it for subtables. """ return self._ismultiused(checksubtables) def name(self): """Return the table name.""" return self._name() def partnames(self, recursive=False): """Return the names of the tables this table consists of. A table can be a reference to another table (e.g. for a selection) or a concatenation of other tables. This function returns the names of such table parts. For a plain table it simply returns the name of that table. In its turn a table part can be a reference or concatenated table. `recursive=True` means that it follows table parts until the end. """ return self._partnames(recursive) def info(self): """Return the table info (table type, subtype, and readme lines).""" return self._info() def putinfo(self, value): """Put the table info. The table info is a dict containing the fields: """ self._putinfo(value) def addreadmeline(self, value): """Add a readme line to the table info.""" self._addreadmeline(value) def setmaxcachesize(self, columnname, nbytes): """Set the maximum cache size for the data manager used by the column. It can sometimes be useful to limit the size of the cache used by a column stored with the tiled storage manager. This method requires some more knowledge about the table system and is not meant for the casual user. """ self._setmaxcachesize(columnname, nbytes) def rownumbers(self, table=None): """Return a list containing the row numbers of this table. This method can be useful after a selection or a sort. It returns the row numbers of the rows in this table with respect to the given table. If no table is given, the original table is used. For example:: t = table('W53.MS') t1 = t.selectrows([1,3,5,7,9]) # select a few rows t1.rownumbers(t) # [1 3 5 7 9] t2 = t1.selectrows([2,5]) # select rows from the selection t2.rownumbers(t1) # [2 5] # rownrs of t2 in table t1 t2.rownumbers(t) # [3 9] # rownrs of t2 in t t2.rownumbers() # [3 9] The last statements show that the method returns the row numbers referring to the given table. Table t2 contains rows 2 and 5 in table t1, which are rows 3 and 9 in table t. """ if table is None: return self._rownumbers(Table()) return self._rownumbers(table) def colnames(self): """Get the names of all columns in the table.""" return self._colnames() def isscalarcol(self, columnname): """Tell if the column contains scalar values.""" return self._isscalarcol(columnname) def isvarcol(self, columnname): """Tell if the column holds variable shaped arrays.""" desc = self.getcoldesc(columnname) return 'ndim' in desc and 'shape' not in desc def coldatatype(self, columnname): """Get the data type of a column. It returns a string which can have the values: ``boolean integer float double complex dcomplex string record`` """ return self._coldatatype(columnname) def colarraytype(self, columnname): """Get the array type of a column holding arrays. It tells if an array is fixed or variable shaped and if it is stored directly or indirectly. This is done by means of a string like ``Indirect, variable sized arrays`` """ return self._colarraytype(columnname) def ncols(self): """Return the number of columns in the table.""" return self._ncols() def nrows(self): """Return the number of rows in the table.""" return self._nrows() def addrows(self, nrows=1): """Add one or more rows to the table.""" self._addrows(nrows) def removerows(self, rownrs): """Remove the given rows from the table. The row numbers can be given in a sequence in any order. The rows will be removed from the end of the table towards the beginning. This is needed because the removal of a row decrements the row number of higher rows. Thus:: t.removerow ([10,20]) is different from:: t.removerow(10) t.removerow(20) because in the latter row 20 was row 21 before the removal of row 10. Some storage managers (in particular the tiled ones) do not allow removal of rows, so the operation may fail. Rows can always be removed from a reference table. It does NOT remove the rows from the referenced table. """ self._removerows(rownrs) def getcolshapestring(self, columnname, startrow=0, nrow=-1, rowincr=1): """Get the shapes of all cells in the column in string format. It returns the shape in a string like [10,20,30]. If the column contains fixed shape arrays, a single shape is returned. Otherwise a list of shape strings is returned. The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). """ return self._getcolshapestring(columnname, startrow, nrow, rowincr, True); # reverse axes def iscelldefined(self, columnname, rownr): """Tell if a column cell contains a value. Columns containing variable shaped arrays can be empty. For these cases this method returns True. Doing :func:`getcell` on an empty cell results in an exception. Note that an empty cell is not the same as an empty array. A cell can contain an empty array (of any dimensionality) as a value. Also note that a cell in a column containing scalars or fixed shaped arrays cannot be empty. """ return self._iscelldefined(columnname, rownr) def getcell(self, columnname, rownr): """Get data from a column cell. Get the contents of a cell which can be returned as a scalar value, a numpy array, or a dict depending on the contents of the cell. """ return self._getcell(columnname, rownr) def getcellnp(self, columnname, rownr, nparray): """Get data from a column cell into the given numpy array . Get the contents of a cell containing an array into the given numpy array. The numpy array has to be C-contiguous with a shape matching the shape of the column cell. Data type coercion will be done as needed. """ if not nparray.flags.c_contiguous or nparray.size == 0: raise ValueError("Argument 'nparray' has to be a contiguous numpy array") return self._getcellvh(columnname, rownr, nparray) def getcellslice(self, columnname, rownr, blc, trc, inc=[]): """Get a slice from a column cell holding an array. The columnname and (0-relative) rownr indicate the table cell. The slice to get is defined by the blc, trc, and optional inc arguments. (blc = bottom-left corner, trc=top-right corner, inc=stride). Not all axes have to be filled in for blc, trc, and inc. Missing axes default to begin, end, and 1. A negative blc or trc defaults to begin or end. Note that trc is inclusive (unlike python indexing). """ return self._getcellslice(columnname, rownr, blc, trc, inc) def getcellslicenp(self, columnname, nparray, rownr, blc, trc, inc=[]): """Get a slice from a column cell into the given numpy array. The columnname and (0-relative) rownr indicate the table cell. The numpy array has to be C-contiguous with a shape matching the shape of the slice. Data type coercion will be done as needed. The slice to get is defined by the blc, trc, and optional inc arguments. (blc = bottom-left corner, trc=top-right corner, inc=stride). Not all axes have to be filled in for blc, trc, and inc. Missing axes default to begin, end, and 1. A negative blc or trc defaults to begin or end. Note that trc is inclusive (unlike python indexing). """ if not nparray.flags.c_contiguous or nparray.size == 0: raise ValueError("Argument 'nparray' has to be a contiguous numpy array") return self._getcellslicevh(columnname, rownr, blc, trc, inc, nparray) def getcol(self, columnname, startrow=0, nrow=-1, rowincr=1): """Get the contents of a column or part of it. It is returned as a numpy array. If the column contains arrays, they should all have the same shape. An exception is thrown if they differ in shape. In that case the method :func:`getvarcol` should be used instead. The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). """ # try: # trial code to read using a vector of rownrs # nr = len(startrow) # if nrow < 0: # nrow = nr # if nrow == 0: # return numpy.array() # for inx in range(nrow): # i = inx* # except: return self._getcol(columnname, startrow, nrow, rowincr) def getcolnp(self, columnname, nparray, startrow=0, nrow=-1, rowincr=1): """Get the contents of a column or part of it into the given numpy array. The numpy array has to be C-contiguous with a shape matching the shape of the column (part). Data type coercion will be done as needed. If the column contains arrays, they should all have the same shape. An exception is thrown if they differ in shape. In that case the method :func:`getvarcol` should be used instead. The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). """ if (not nparray.flags.c_contiguous) or nparray.size == 0: raise ValueError("Argument 'nparray' has to be a contiguous numpy array") return self._getcolvh(columnname, startrow, nrow, rowincr, nparray) def getvarcol(self, columnname, startrow=0, nrow=-1, rowincr=1): """Get the contents of a column or part of it. It is similar to :func:`getcol`, but the result is returned as a dict of numpy arrays. It can deal with a column containing variable shaped arrays. """ return self._getvarcol(columnname, startrow, nrow, rowincr) def getcolslice(self, columnname, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1): """Get a slice from a table column holding arrays. The slice in each array is given by blc, trc, and inc (as in getcellslice). The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). It returns a numpy array where the first axis is formed by the column cells. The other axes are the array axes. """ return self._getcolslice(columnname, blc, trc, inc, startrow, nrow, rowincr) def getcolslicenp(self, columnname, nparray, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1): """Get a slice from a table column into the given numpy array. The numpy array has to be C-contiguous with a shape matching the shape of the column (slice). Data type coercion will be done as needed. The slice in each array is given by blc, trc, and inc (as in getcellslice). The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). It returns a numpy array where the first axis is formed by the column cells. The other axes are the array axes. """ if not nparray.flags.c_contiguous or nparray.size == 0: raise ValueError("Argument 'nparray' has to be a contiguous numpy array") return self._getcolslicevh(columnname, blc, trc, inc, startrow, nrow, rowincr, nparray) def putcell(self, columnname, rownr, value): """Put a value into one or more table cells. The columnname and (0-relative) rownrs indicate the table cells. rownr can be a single row number or a sequence of row numbers. If multiple rownrs are given, the given value is put in all those rows. The given value has to be convertible to the data type of the column. If the column contains scalar values, the given value must be a scalar. The value for a column holding arrays can be given as: - a scalar resulting in a 1-dim array of 1 element - a sequence (list, tuple) resulting in a 1-dim array - a numpy array of any dimensionality Note that the arrays in a column may have a fixed dimensionality or shape. In that case the dimensionality or shape of the array to put has to conform. """ self._putcell(columnname, rownr, value) def putcellslice(self, columnname, rownr, value, blc, trc, inc=[]): """Put into a slice of a table cell holding an array. The columnname and (0-relative) rownr indicate the table cell. Unlike putcell only a single row can be given. The slice to put is defined by the blc, trc, and optional inc arguments. (blc = bottom-left corner, trc=top-right corner, inc=stride). Not all axes have to be filled in for blc, trc, and inc. Missing axes default to begin, end, and 1. A negative blc or trc defaults to begin or end. Note that trc is inclusive (unlike python indexing). As in putcell the array can be given by a scalar, sequence, or numpy array. The shape of the array to put has to match the slice shape. """ self._putcellslice(columnname, rownr, value, blc, trc, inc) def putcol(self, columnname, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. If the column contains scalar values, the given value should be a 1-dim array. Otherwise it is a numpy array where the first axis is formed by the column cells. The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). """ self._putcol(columnname, startrow, nrow, rowincr, value) def putvarcol(self, columnname, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. It is similar to putcol, but the shapes of the arrays in the column can vary. The value has to be a dict of numpy arrays. The column can be sliced by giving a start row (default 0), number of rows (default all), and row stride (default 1). """ self._putvarcol(columnname, startrow, nrow, rowincr, value) def putcolslice(self, columnname, value, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1): """Put into a slice in a table column holding arrays. Its arguments are the same as for getcolslice and putcellslice. """ self._putcolslice(columnname, value, blc, trc, inc, startrow, nrow, rowincr) def addcols(self, desc, dminfo={}, addtoparent=True): """Add one or more columns. Columns can always be added to a normal table. They can also be added to a reference table and optionally to its parent table. `desc` contains a description of the column(s) to be added. It can be given in three ways: - a dict created by :func:`maketabdesc`. In this way multiple columns can be added. - a dict created by :func:`makescacoldesc`, :func:`makearrcoldesc`, or :func:`makecoldesc`. In this way a single column can be added. - a dict created by :func:`getcoldesc`. The key 'name' containing the column name has to be defined in such a dict. `dminfo` can be used to provide detailed data manager info to tell how the column(s) have to be stored. The dminfo of an existing column can be obtained using method :func:`getdminfo`. `addtoparent` defines if the column should also be added to the parent table in case the current table is a reference table (result of selection). If True, it will be added to the parent if it does not exist yet. For example, add a column using the same data manager type as another column:: coldmi = t.getdminfo('colarrtsm') # get dminfo of existing column coldmi["NAME"] = 'tsm2' # give it a unique name t.addcols (maketabdesc(makearrcoldesc("colarrtsm2",0., ndim=2)), coldmi) """ tdesc = desc # Create a tabdesc if only a coldesc is given. if 'name' in desc: import casacore.tables.tableutil as pt if len(desc) == 2 and 'desc' in desc: # Given as output from makecoldesc tdesc = pt.maketabdesc(desc) elif 'valueType' in desc: # Given as output of getcoldesc (with a name field added) cd = pt.makecoldesc(desc['name'], desc) tdesc = pt.maketabdesc(cd) self._addcols(tdesc, dminfo, addtoparent) self._makerow() def renamecol(self, oldname, newname): """Rename a single table column. Renaming a column in a reference table does NOT rename the column in the referenced table. """ self._renamecol(oldname, newname) self._makerow() def removecols(self, columnnames): """Remove one or more columns. Note that some storage managers (in particular the tiled ones) do not allow the removal of one of its columns. In that case all its columns have to be removed together. Columns can always be removed from a reference table. It does NOT remove the columns from the referenced table. """ self._removecols(columnnames) self._makerow() def keywordnames(self): """Get the names of all table keywords.""" return self._getfieldnames('', '', -1) def colkeywordnames(self, columnname): """Get the names of all keywords of a column.""" return self._getfieldnames(columnname, '', -1) def fieldnames(self, keyword=''): """Get the names of the fields in a table keyword value. The value of a keyword can be a struct (python dict). This method returns the names of the fields in that struct. Each field in a struct can be a struct in itself. Names of fields in a sub-struct can be obtained by giving a keyword name consisting of multiple parts separated by dots (e.g. 'key1.sub1.sub2'). If an empty keyword name is given (which is the default), all table keyword names are shown and its behaviour is the same as :func:`keywordnames`. Instead of a keyword name an index can be given which returns the names of the struct value of the i-th keyword. """ if isinstance(keyword, str): return self._getfieldnames('', keyword, -1) else: return self._getfieldnames('', '', keyword) def colfieldnames(self, columnname, keyword=''): """Get the names of the fields in a column keyword value. The value of a keyword can be a struct (python dict). This method returns the names of the fields in that struct. Each field in a struct can be a struct in itself. Names of fields in a sub-struct can be obtained by giving a keyword name consisting of multiple parts separated by dots (e.g. 'key1.sub1.sub2'). If an empty keyword name is given (which is the default), all keyword names of the column are shown and its behaviour is the same as :func:`colkeywordnames`. Instead of a keyword name an index can be given which returns the names of the struct value of the i-th keyword. """ if isinstance(keyword, str): return self._getfieldnames(columnname, keyword, -1) else: return self._getfieldnames(columnname, '', keyword) def getkeyword(self, keyword): """Get the value of a table keyword. The value of a keyword can be a: - scalar which is returned as a normal python scalar. - an array which is returned as a numpy array. - a reference to a table which is returned as a string containing its name prefixed by 'Table :'. It can be opened using the normal table constructor which will remove the prefix. - a struct which is returned as a dict. A struct is fully nestable, thus each field in the struct can have one of the values described here. Similar to method :func:`fieldnames` a keyword name can be given consisting of multiple parts separated by dots. This represents nested structs, thus gives the value of a field in a struct (in a struct, etc.). Instead of a keyword name an index can be given which returns the value of the i-th keyword. """ if isinstance(keyword, str): return self._getkeyword('', keyword, -1) else: return self._getkeyword('', '', keyword) def getcolkeyword(self, columnname, keyword): """Get the value of a column keyword. It is similar to :func:`getkeyword`. """ if isinstance(keyword, str): return self._getkeyword(columnname, keyword, -1) else: return self._getkeyword(columnname, '', keyword) def getkeywords(self): """Get the value of all table keywords. It is returned as a dict. See :func:`getkeyword` for the possible value types. """ return self._getkeywords('') def getcolkeywords(self, columnname): """Get the value of all keywords of a column. It is returned as a dict. See :func:`getkeyword` for the possible value types. """ return self._getkeywords(columnname) def getsubtables(self): """Get the names of all subtables.""" keyset = self.getkeywords() names = [] for key, value in keyset.items(): if isinstance(value, str) and value.find('Table: ') == 0: names.append(_do_remove_prefix(value)) return names def putkeyword(self, keyword, value, makesubrecord=False): """Put the value of a table keyword. The value of a keyword can be a: - scalar which can be given a normal python scalar or numpy scalar. - an array which can be given as a numpy array. A 1-dimensional array can also be given as a sequence (tuple or list). - a reference to a table which can be given as a table object or as a string containing its name prefixed by 'Table :'. - a struct which can be given as a dict. A struct is fully nestable, thus each field in the dict can be one of the values described here. The only exception is that a table value can only be given by the string. If the keyword already exists, the type of the new value should match the existing one (e.g. a scalar cannot be replaced by an array). Similar to method :func:`getkeyword` a keyword name can be given consisting of multiple parts separated by dots. This represents nested structs, thus puts the value into a field in a struct (in a struct, etc.). If `makesubrecord=True` structs will be created for the keyword name parts that do not exist. Instead of a keyword name an index can be given which returns the value of the i-th keyword. """ val = value if isinstance(val, table): val = _add_prefix(val.name()) if isinstance(keyword, str): return self._putkeyword('', keyword, -1, makesubrecord, val) else: return self._putkeyword('', '', keyword, makesubrecord, val) def putcolkeyword(self, columnname, keyword, value, makesubrecord=False): """Put the value of a column keyword. It is similar to :func:`putkeyword`. """ val = value if isinstance(val, table): val = _add_prefix(val.name()) if isinstance(keyword, str): return self._putkeyword(columnname, keyword, -1, makesubrecord, val) else: return self._putkeyword(columnname, '', keyword, makesubrecord, val) def putkeywords(self, value): """Put the value of multiple table keywords. The value has to be a dict, so each field in the dict is a keyword. It puts all keywords similar to :func:`putkeyword`. """ return self._putkeywords('', value) def putcolkeywords(self, columnname, value): """Put the value of multiple keywords in a column. The value has to be a dict, so each field in the dict is a keyword. It puts all keywords similar to :func:`putkeyword`. """ return self._putkeywords(columnname, value) def removekeyword(self, keyword): """Remove a table keyword. Similar to :func:`getkeyword` the name can consist of multiple parts. In that case a field in a struct will be removed. Instead of a keyword name an index can be given which removes the i-th keyword. """ if isinstance(keyword, str): self._removekeyword('', keyword, -1) else: self._removekeyword('', '', keyword) def removecolkeyword(self, columnname, keyword): """Remove a column keyword. It is similar to :func:`removekeyword`. """ if isinstance(keyword, str): self._removekeyword(columnname, keyword, -1) else: self._removekeyword(columnname, '', keyword) def getdesc(self, actual=True): """Get the table description. By default it returns the actual description (thus telling the actual array shapes and data managers used). `actual=False` means that the original description as made by :func:`maketabdesc` is returned. """ tabledesc = self._getdesc(actual, True) # Strip out 0 length "HCcoordnames" and "HCidnames" # as these aren't valid. (See tabledefinehypercolumn) hcdefs = tabledesc.get('_define_hypercolumn_', {}) for c, hcdef in hcdefs.iteritems(): if "HCcoordnames" in hcdef and len(hcdef["HCcoordnames"]) == 0: del hcdef["HCcoordnames"] if "HCidnames" in hcdef and len(hcdef["HCidnames"]) == 0: del hcdef["HCidnames"] return tabledesc def getcoldesc(self, columnname, actual=True): """Get the description of a column. By default it returns the actual description (thus telling the actual array shapes and data managers used). `actual=False` means that the original description as made by :func:`makescacoldesc` or :func:`makearrcoldesc` is returned. """ return self._getcoldesc(columnname, actual, True) def coldesc(self, columnname, actual=True): """Make the description of a column. Make the description object of the given column like :func:`makecoldesc` is doing with the description given by :func:`getcoldesc`. """ import casacore.tables.tableutil as pt return pt.makecoldesc(columnname, self.getcoldesc(columnname, actual)) def getdminfo(self, columnname=None): """Get data manager info. Each column in a table is stored using a data manager. A storage manager is a data manager storing the physically in a file. A virtual column engine is a data manager that does not store data but calculates it on the fly (e.g. scaling floats to short to reduce storage). By default this method returns a dict telling the data managers used. Each field in the dict is a dict containing: - NAME telling the (unique) name of the data manager - TYPE telling the type of data manager (e.g. TiledShapeStMan) - SEQNR telling the sequence number of the data manager (is ''i'' in table.f for storage managers) - SPEC is a dict holding the data manager specification - COLUMNS is a list giving the columns stored by this data manager When giving a column name the data manager info of that particular column is returned (without the COLUMNS field). It can, for instance, be used when adding a column using :func:`addcols` that should use the same data manager type as an existing column. However, when doing that care should be taken to change the NAME because each data manager name has to be unique. """ dminfo = self._getdminfo() if columnname is None: return dminfo # Find the info for the given column for fld in dminfo.values(): if columnname in fld["COLUMNS"]: fldc = fld.copy() del fldc['COLUMNS'] # remove COLUMNS field return fldc raise KeyError("Column " + columnname + " does not exist") def getdmprop(self, name, bycolumn=True): """Get properties of a data manager. Each column in a table is stored using a data manager. A storage manager is a data manager storing the physically in a file. A virtual column engine is a data manager that does not store data but calculates it on the fly (e.g. scaling floats to short to reduce storage). Some data managers have properties that can be changed on the fly (e.g. cachesize for a tiled storage manager). The properties of a given data manager are returned as a dict; function :func:`setdmprop` can be used to change the properties. Note the properties are also part of the data manager info returned by :func:`getdminfo`. The data manager can be specified in two ways: by data manager name or by the name of a column using the data manager. The argument `bycolumn` defines which way is used (default is by column name). """ return self._getdmprop(name, bycolumn) def setdmprop(self, name, properties, bycolumn=True): """Set properties of a data manager. Properties (e.g. cachesize) of a data manager can be changed by defining them appropriately in the properties argument (a dict). Current values can be obtained using function :func:`getdmprop` which also serves as a template. The dict can contain more fields; only the fields with the names as returned by getdmprop are handled. The data manager can be specified in two ways: by data manager name or by the name of a column using the data manager. The argument `bycolumn` defines which way is used (default is by column name). """ return self._setdmprop(name, properties, bycolumn) def showstructure(self, dataman=True, column=True, subtable=False, sort=False): """Show table structure in a formatted string. The structure of this table and optionally its subtables is shown. It shows the data manager info and column descriptions. Optionally the columns are sorted in alphabetical order. `dataman` Show data manager info? If False, only column info is shown. If True, data manager info and columns per data manager are shown. `column` Show column description per data manager? Only takes effect if dataman=True. `subtable` Show the structure of all subtables (recursively). The names of subtables are always shown. 'sort' Sort the columns in alphabetical order? """ return self._showstructure(dataman, column, subtable, sort) def summary(self, recurse=False): """Print a summary of the table. It prints the number of columns and rows, column names, and table and column keywords. If `recurse=True` it also prints the summary of all subtables, i.e. tables referenced by table keywords. """ six.print_('Table summary:', self.name()) six.print_('Shape:', self.ncols(), 'columns by', self.nrows(), 'rows') six.print_('Info:', self.info()) tkeys = self.getkeywords() if (len(tkeys) > 0): six.print_('Table keywords:', tkeys) columns = self.colnames() if (len(columns) > 0): six.print_('Columns:', columns) for column in columns: ckeys = self.getcolkeywords(column) if (len(ckeys) > 0): six.print_(column, 'keywords:', ckeys) if (recurse): for key, value in tkeys.items(): tabname = _remove_prefix(value) six.print_('Summarizing subtable:', tabname) lt = table(tabname) if (not lt.summary(recurse)): break return True def selectrows(self, rownrs): """Return a reference table containing the given rows.""" t = self._selectrows(rownrs, name='') # selectrows returns a Table object, so turn that into table. return table(t, _oper=3) def query(self, query='', name='', sortlist='', columns='', limit=0, offset=0, style='Python'): """Query the table and return the result as a reference table. This method queries the table. It forms a `TaQL <../../doc/199.html>`_ command from the given arguments and executes it using the :func:`taql` function. The result is returned in a so-called reference table which references the selected columns and rows in the original table. Usually a reference table is temporary, but it can be made persistent by giving it a name. Note that a reference table is handled as any table, thus can be queried again. All arguments are optional, but at least one of `query`, `name`, `sortlist`, and `columns` should be used. See the `TaQL note <../../doc/199.html>`_ for the detailed description of the the arguments representing the various parts of a TaQL command. `query` The WHERE part of a TaQL command. `name` The name of the reference table if it is to be made persistent. `sortlist` The ORDERBY part of a TaQL command. It is a single string in which commas have to be used to separate sort keys. `columns` The columns to be selected (projection in data base terms). It is a single string in which commas have to be used to separate column names. Apart from column names, expressions can be given as well. `limit` If > 0, maximum number of rows to be selected. `offset` If > 0, ignore the first N matches. `style` The TaQL syntax style to be used (defaults to Python). """ if not query and not sortlist and not columns and limit <= 0 and offset <= 0: raise ValueError('No selection done (arguments query, sortlist, columns, limit, and offset are empty)') command = 'select ' if columns: command += columns command += ' from $1' if query: command += ' where ' + query if sortlist: command += ' orderby ' + sortlist if limit > 0: command += ' limit %d' % limit if offset > 0: command += ' offset %d' % offset if name: command += ' giving ' + name return tablecommand(command, style, [self]) def sort(self, sortlist, name='', limit=0, offset=0, style='Python'): """Sort the table and return the result as a reference table. This method sorts the table. It forms a `TaQL <../../doc/199.html>`_ command from the given arguments and executes it using the :func:`taql` function. The result is returned in a so-called reference table which references the columns and rows in the original table. Usually a reference table is temporary, but it can be made persistent by giving it a name. Note that a reference table is handled as any table, thus can be queried again. `sortlist` The ORDERBY part of a TaQL command. It is a single string in which commas have to be used to separate sort keys. A sort key can be the name of a column, but it can be an expression as well. `name` The name of the reference table if it is to be made persistent. `limit` If > 0, maximum number of rows to be selected after the sort step. It can, for instance, be used to select the N highest values. `offset` If > 0, ignore the first `offset` matches after the sort step. `style` The TaQL syntax style to be used (defaults to Python). """ command = 'select from $1 orderby ' + sortlist if limit > 0: command += ' limit %d' % limit if offset > 0: command += ' offset %d' % offset if name: command += ' giving ' + name return tablecommand(command, style, [self]) def select(self, columns, name='', style='Python'): """Select columns and return the result as a reference table. This method represents the SELECT part of a TaQL command using the given columns (or column expressions). It forms a `TaQL <../../doc/199.html>`_ command from the given arguments and executes it using the :func:`taql` function. The result is returned in a so-called reference table which references the columns and rows in the original table. Usually a reference table is temporary, but it can be made persistent by giving it a name. Note that a reference table is handled as any table, thus can be queried again. `columns` The columns to be selected (projection in data base terms). It is a single string in which commas have to be used to separate column names. Apart from column names, expressions can be given as well. `name` The name of the reference table if it is to be made persistent. `style` The TaQL syntax style to be used (defaults to Python). """ command = 'select ' + columns + ' from $1' if name: command += ' giving ' + name return tablecommand(command, style, [self]) def calc(self, expr, style='Python'): """Do a TaQL calculation The TaQL CALC command can be used to get the result of a calculation on table data. It is, however, also possible to use it without table data. For instance, to use it for converting units:: t = table('',{}) t.calc ('(1 \in)cm') `expr` The CALC expression `style` The TaQL syntax style to be used (defaults to Python). """ return tablecommand('calc from $1 calc ' + expr, style, [self]) def browse(self, wait=True, tempname="/tmp/seltable"): """ Browse a table using casabrowser or a simple wxwidget based browser. By default the casabrowser is used if it can be found (in your PATH). Otherwise the wxwidget one is used if wx can be loaded. The casabrowser can only browse tables that are persistent on disk. This gives problems for tables resulting from a query because they are held in memory only (unless an output table name was given). To make browsing of such tables possible, the argument `tempname` can be used to specify a table name that will be used to form a persistent table that can be browsed. Note that such a table is very small as it does not contain data, but only references to rows in the original table. The default for `tempname` is '/tmp/seltable'. If needed, the table can be deleted using the :func:`tabledelete` function. If `wait=False`, the casabrowser is started in the background. In that case the user should delete a possibly created copy of a temporary table. """ import os # Test if casabrowser can be found. # On OS-X 'which' always returns 0, so use test on top of it. if os.system('test -x `which casabrowser` > /dev/null 2>&1') == 0: waitstr1 = "" waitstr2 = "foreground ..." if not wait: waitstr1 = " &" waitstr2 = "background ..." if self.iswritable(): six.print_("Flushing data and starting casabrowser in the " + waitstr2) else: six.print_("Starting casabrowser in the " + waitstr2) self.flush() self.unlock() if os.system('test -e ' + self.name() + '/table.dat') == 0: os.system('casabrowser ' + self.name() + waitstr1) elif len(tempname) > 0: six.print_(" making a persistent copy in table " + tempname) self.copy(tempname) os.system('casabrowser ' + tempname + waitstr1) if wait: from casacore.tables import tabledelete six.print_(" finished browsing") tabledelete(tempname) else: six.print_(" after browsing use tabledelete('" + tempname + "') to delete the copy") else: six.print_("Cannot browse because the table is in memory only.") six.print_("You can browse a (shallow) persistent copy of the table like: ") six.print_(" t.browse(True, '/tmp/tab1')") else: try: import wxPython except ImportError: six.print_('casabrowser nor wx available') return from wxPython.wx import wxPySimpleApp import sys app = wxPySimpleApp() from wxtablebrowser import CasaTestFrame frame = CasaTestFrame(None, sys.stdout, self) frame.Show(True) app.MainLoop() def view(self, wait=True, tempname="/tmp/seltable"): """ View a table using casaviewer, casabrowser, or wxwidget based browser. The table is viewed depending on the type: MeasurementSet is viewed using casaviewer. Image is viewed using casaviewer. other are browsed using the :func:`browse` function. If the casaviewer cannot be found, all tables are browsed. The casaviewer can only display tables that are persistent on disk. This gives problems for tables resulting from a query because they are held in memory only (unless an output table name was given). To make viewing of such tables possible, the argument `tempname` can be used to specify a table name that will be used to form a persistent table that can be browsed. Note that such a table is very small as it does not contain data, but only references to rows in the original table. The default for `tempname` is '/tmp/seltable'. If needed, the table can be deleted using the :func:`tabledelete` function. If `wait=False`, the casaviewer is started in the background. In that case the user should delete a possibly created copy of a temporary table. """ import os # Determine the table type. # Test if casaviewer can be found. # On OS-X 'which' always returns 0, so use test on top of it. viewed = False type = self.info()["type"] if type == "Measurement Set" or type == "Image": if os.system('test -x `which casaviewer` > /dev/null 2>&1') == 0: waitstr1 = "" waitstr2 = "foreground ..." if not wait: waitstr1 = " &" waitstr2 = "background ..." if self.iswritable(): six.print_("Flushing data and starting casaviewer in the " + waitstr2) else: six.print_("Starting casaviewer in the " + waitstr2) self.flush() self.unlock() if os.system('test -e ' + self.name() + '/table.dat') == 0: os.system('casaviewer ' + self.name() + waitstr1) viewed = True elif len(tempname) > 0: six.print_(" making a persistent copy in table " + tempname) self.copy(tempname) os.system('casaviewer ' + tempname + waitstr1) viewed = True if wait: from casacore.tables import tabledelete six.print_(" finished viewing") tabledelete(tempname) else: six.print_(" after viewing use tabledelete('" + tempname + "') to delete the copy") else: six.print_("Cannot browse because the table is in memory only.") six.print_("You can browse a (shallow) persistent copy of the table like:") six.print_(" t.view(True, '/tmp/tab1')") # Could not view the table, so browse it. if not viewed: self.browse(wait, tempname) def _repr_html_(self): """Give a nice representation of tables in notebooks.""" out="\n" # Print column names (not if they are all auto-generated) if not(all([colname[:4]=="Col_" for colname in self.colnames()])): out+="" for colname in self.colnames(): out+="" out+="" cropped=False rowcount=0 for row in self: rowout=_format_row(row, self.colnames(),self) rowcount+=1 out+=rowout if "\n" in rowout: # Double space after multiline rows out+="\n" out+="\n" if rowcount>=20: cropped=True break if out[-2:]=="\n\n": out=out[:-1] out+="
"+colname+"
" if cropped: out+="

("+str(self.nrows()-20)+" more rows)

\n" return out python-casacore-2.2.1/casacore/tables/tablecolumn.py000066400000000000000000000305461320311315100225220ustar00rootroot00000000000000# tablecolumn.py: Python tablecolumn functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: tablecolumn.py,v 1.9 2007/08/28 07:22:18 gvandiep Exp $ from .table import table from .tablehelper import _check_key_slice, _do_remove_prefix, _format_cell class tablecolumn: """The Python interface to a column in a Casacore table. The `tablecolumn` class is a convenience class to access data in a table column. All functionality provided in this class is available in :class:`table`, but `tablecolumn` is more convenient to use because the column name does not have to be given over and over again. For example:: t = table('3C343.MS') tc = tablecolumn(t, 'DATA') # tc = t.col('DATA') # another way to construct a tablecolumn tc.getcell(0) # get data from cell 0 As can be seen in the example :func:`table.col` offers a slightly more convenient way to create a `tablecolumn` object. A `tablecolumn` can be indexed using Python's [] operator. Negative start, end, and stride is possible. For example:: tc[0] # get cell 0 tc[:5] # get cell 0,1,2,3,4 tc[-5,-1,] # get last 4 cells tc[-1,-5,-1] # get last 4 cells in reversed order tc[1] = tr[0] # put value of cell 0 into cell 1 The `tablecolumn` class supports the context manager idiom (__enter__ and __exit__). When used in a `with` statement, the table changes will be flushed automatically, which is handy when writing to the table column. For example:: with t.SPECTRAL_WINDOW_ID as tc: tc.putcell (0, 0) """ def __init__(self, table, columnname): if columnname not in table.colnames(): raise RuntimeError("Column " + columnname + " does not exist in table " + table.name()) self._table = table self._column = columnname def __enter__(self): """Function to enter a with block.""" return self def __exit__(self, type, value, traceback): """Function to exit a with block which flushes the table object.""" self._table.flush() def name(self): """Get the name of the column.""" return self._column def table(self): """Get the table object this column belongs to.""" return self._table def isscalar(self): """Tell if the column contains scalar values.""" return self._table.isscalarcol(self._column) def isvar(self): """Tell if the column holds variable shaped arrays.""" return self._table.isvarcol(self._column) def datatype(self): """Get the data type of the column. (see :func:`table.coldatatype`)""" return self._table.coldatatype(self._column) def arraytype(self): """Get the array type of a column holding arrays. (see :func:`table.colarraytype`)""" return self._table.colarraytype(self._column) def nrows(self): """Get number of cells in the column.""" return self._table.nrows() def getshapestring(self, startrow=1, nrow=-1, rowincr=1): """Get the shapes of all cells in the column in string format. (see :func:`table.getcolshapestring`)""" return self._table.getcolshapestring(self._column, startrow, nrow, rowincr) def iscelldefined(self, rownr): """Tell if a column cell contains a value. (see :func:`table.iscelldefined`)""" return self._table.iscelldefined(self._column, rownr) def getcell(self, rownr): """Get data from a column cell. (see :func:`table.getcell`)""" return self._table.getcell(self._column, rownr) def getcellslice(self, rownr, blc, trc, inc=[]): """Get a slice from a column cell holding an array. (see :func:`table.getcellslice`)""" return self._table.getcellslice(self._column, rownr, blc, trc, inc) def getcol(self, startrow=0, nrow=-1, rowincr=1): """Get the contents of the column or part of it. (see :func:`table.getcol`)""" return self._table.getcol(self._column, startrow, nrow, rowincr) def getvarcol(self, startrow=0, nrow=-1, rowincr=1): """Get the contents of the column or part of it. (see :func:`table.getvarcol`)""" return self._table.getvarcol(self._column, startrow, nrow, rowincr) def getcolslice(self, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1): """Get a slice from a table column holding arrays. (see :func:`table.getcolslice`)""" return self._table.getcolslice(self._column, blc, trc, inc, startrow, nrow, rowincr) def putcell(self, rownr, value): """Put a value into one or more table cells. (see :func:`table.putcell`)""" return self._table.putcell(self._column, rownr, value) def putcellslice(self, rownr, value, blc, trc, inc=[]): """Put into a slice of a table cell holding an array. (see :func:`table.putcellslice`)""" return self._table.putcellslice(self._column, rownr, value, blc, trc, inc) def putcol(self, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. (see :func:`table.putcol`)""" return self._table.putcol(self._column, value, startrow, nrow, rowincr) def putvarcol(self, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. (see :func:`table.putvarcol`)""" return self._table.putvarcol(self._column, value, startrow, nrow, rowincr) def putcolslice(self, value, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1): """Put into a slice in a table column holding arrays. (see :func:`table.putcolslice`)""" return self._table.putcolslice(self._column, value, blc, trc, inc, startrow, nrow, rowincr) def keywordnames(self): """Get the names of all keywords of the column.""" return self._table.colkeywordnames(self._column) def fieldnames(self, keyword=''): """Get the names of the fields in a column keyword value. (see :func:`table.colfieldnames`)""" return self._table.colfieldnames(self._column, keyword) def getkeyword(self, keyword): """Get the value of a column keyword. (see :func:`table.getcolkeyword`)""" return self._table.getcolkeyword(self._column, keyword) def getkeywords(self): """Get the value of all keywords of the column. (see :func:`table.getcolkeywords`)""" return self._table.getcolkeywords(self._column) def putkeyword(self, keyword, value, makesubrecord=False): """Put the value of a column keyword. (see :func:`table.putcolkeyword`)""" return self._table.putcolkeyword(self._column, keyword, value, makesubrecord) def putkeywords(self, value): """Put the value of multiple table keywords. (see :func:`table.putcolkeywords`)""" return self._table.putcolkeywords(self._column, value) def removekeyword(self, keyword): """Remove a column keyword. (see :func:`table.removecolkeyword`)""" return self._table.removecolkeyword(self._column, keyword) def getdesc(self): """Get the description of the column. (see :func:`table.getcoldesc`)""" return self._table.getcoldesc(self._column) def getdminfo(self): """Get data manager info of the column. (see :func:`table.getdminfo`)""" return self._table.getdminfo(self._column) def iter(self, order='', sort=True): """Return a :class:`tableiter` object on this column.""" from casacore.tables import tableiter return tableiter(self._table, [self._column], order, sort) def index(self, sort=True): """Return a :class:`tableindex` object on this column.""" from casacore.tables import tableindex return tableindex(self._table, [self._column], sort) def __len__(self): return self._table.nrows() def __getattr__(self, name): """Get the keyword value. | The value of a column keyword is returned if it names a keyword. If the keyword is a subtable, it opens the table and returns a table object. | The values of all column keywords is returned if name equals _ or keys. An AttributeError is raised if the name is not a keyword. For example:: print tc.MEASINFO # print the column's measure info print tc._ # print all column keywords """ # Try if it is a keyword. try: val = self.getkeyword(name) # See if the keyword represents a subtable and try to open it. if val != _do_remove_prefix(val): try: return table(val, ack=False) except: pass return val except: pass # _ or keys means all keywords. if name in ('_', 'keys'): return self.getkeywords() # Unknown name. raise AttributeError("table has no attribute/keyword " + name) def __getitem__(self, key): """Get the values from one or more rows.""" sei = _check_key_slice(key, self._table.nrows(), 'tablecolumn') if len(sei) == 1: # A single row. return self.getcell(sei[0]) # Handle row by row and store values in a list. result = [] rownr = sei[0] inx = 0 while inx < sei[1]: result.append(self.getcell(rownr)) rownr += sei[2] inx += 1 return result def __setitem__(self, key, value): sei = _check_key_slice(key, self._table.nrows(), 'tablecolumn') if len(sei) == 1: # A single row. return self.putcell(sei[0], value) # Handle row by row. rownr = sei[0] inx = 0 if not (isinstance(value, list) or isinstance(value, tuple)): # The same value is put in all rows. while inx < sei[1]: self.putcell(rownr, value) rownr += sei[2] inx += 1 else: # Each row has its own value. if len(value) != sei[1]: raise RuntimeError( "tablecolumn slice length differs from value length") for val in value: self.putcell(rownr, val) rownr += sei[2] return True def _repr_html_(self): """Give a nice representation of columns in notebooks.""" out="\n" # Print column name (not if it is auto-generated) if not(self.name()[:4]=="Col_"): out+="" out+="" out+="" cropped=False rowcount=0 colkeywords=self.getkeywords() for row in self: out +="\n" out += "\n" out += "\n" rowcount+=1 out+="\n" if rowcount>=20: cropped=True break if out[-2:]=="\n\n": out=out[:-1] out+="
"+self.name()+"
" + _format_cell(row, colkeywords) + "
" if cropped: out+="

("+str(self.nrows()-20)+" more rows)

\n" return out python-casacore-2.2.1/casacore/tables/tablehelper.py000066400000000000000000000230021320311315100224710ustar00rootroot00000000000000# tablehelper.py: Helper table functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: tableutil.py,v 1.6 2006/11/08 00:12:55 gvandiep Exp $ from casacore.six import PY2 import numpy import re from ..quanta import quantity # A keywordset in a table can hold tables, but it is not possible to # pass them around because a ValueHolder cannot deal with it. # Therefore it is passed around as a string with a special prefix. def _add_prefix(name): """Add the prefix 'Table: ' to a table name to get a specific keyword value.""" return 'Table: ' + name def _do_remove_prefix(name): """Strip the possible prefix 'Table: ' from a table name.""" res = name if isinstance(res, str): if (res.find('Table: ') == 0): res = res.replace('Table: ', '', 1) return res def _remove_prefix(name): """Strip the possible prefix 'Table: ' from one or more table names.""" if isinstance(name, str): return _do_remove_prefix(name) return [_do_remove_prefix(nm) for nm in name] def _check_index(key, name): # The __index__ method converts e.g. np.int16 to a proper integer. # An exception is thrown if the type does not have __index__ which # means that the given key cannot be used as an index. try: return key.__index__() except: raise TypeError(name + " indices must be integer (or None in a slice)") # Check a key or slice given to index a tablerow or tablecolumn object. # A TypeError exception is raised if values or not integer or None. # An IndexError is raised if incorrect values are given. # It returns a list of length 1 if a single index is given. # Otherwise it returns [startrow, nrow, step]. def _check_key_slice(key, nrows, name): if not isinstance(key, slice): inx = _check_index(key, name) # A single index (possibly negative, thus from the end). if inx < 0: inx += nrows if inx < 0 or inx >= nrows: raise IndexError(name + " index out of range") return [inx] # Given as start:stop:step where each part is optional and can # be negative. incr = 1 if key.step is not None: incr = _check_index(key.step, name) if incr == 0: raise RuntimeError(name + " slice step cannot be zero") strow = 0 endrow = nrows if incr < 0: strow = nrows - 1 endrow = -1 if key.start is not None: strow = _check_index(key.start, name) if strow < 0: strow += nrows strow = min(max(strow, 0), nrows - 1) if key.stop is not None: endrow = _check_index(key.stop, name) if endrow < 0: endrow += nrows endrow = min(max(endrow, -1), nrows) if incr > 0: nrow = int((endrow - strow + incr - 1) / incr) else: nrow = int((strow - endrow - incr - 1) / -incr) nrow = max(0, nrow) return [strow, nrow, incr] # Convert Python value type to a glish-like type string # as expected by the table code. def _value_type_name(value): if isinstance(value, bool): return 'boolean' if isinstance(value, int): return 'integer' if PY2 and isinstance(value, long): return 'integer' if isinstance(value, float): return 'double' if isinstance(value, complex): return 'dcomplex' if isinstance(value, str): return 'string' if isinstance(value, dict): return 'record' return 'unknown' def _format_date(val, unit): """ Format dates. :param val: Value (just the value, not a quantity) :param unit: Unit. Should be 'rad' or 's' :return: A string representation of this date. >>> _format_date(4914741782.503475, 's') "14-Aug-2014/14:03:03" """ if val==numpy.floor(val) and unit=='d': # Do not show time part if 0 return quantity(val,unit).formatted('YMD_ONLY') else: return quantity(val,unit).formatted('DMY') def _format_quantum(val, unit): """ Format a quantity with reasonable units. :param val: The value (just the value, not a quantity) :param unit: Unit (something that can be fed to quanta). :return: A string representation of this quantity. >>> _format_quantum(3, 'm') "3 m" >>> _format_quantum(4914741782.503475, 's') "4.91474e+09 s" """ q=quantity(val,unit) if q.canonical().get_unit() in ['rad','s']: return quantity(val, 'm').formatted()[:-1]+unit else: return q.formatted() def _format_cell(val, colkeywords): """ Format a cell of the table. Colkeywords can add units. :param val: A plain value (not a quantum) :param colkeywords: :return: A HTML representation of this cell. """ out="" # String arrays are returned as dict, undo that for printing if isinstance(val, dict): tmpdict=numpy.array(val['array']) tmpdict.reshape(val['shape']) # Leave out quotes around strings numpy.set_printoptions(formatter={'all':lambda x: str(x)}) out+=numpy.array2string(tmpdict, separator=', ') # Revert previous numpy print options numpy.set_printoptions(formatter=None) else: valtype='other' # Check if the column unit is like 'm' or ['m','m','m'] singleUnit=('QuantumUnits' in colkeywords and (numpy.array(colkeywords['QuantumUnits'])==numpy.array(colkeywords['QuantumUnits'])[0]).all()) if colkeywords.get('MEASINFO',{}).get('type')=='epoch' and singleUnit: # Format a date/time. Use quanta for scalars, use numpy for array logic around it # (quanta does not support higher dimensional arrays) valtype='epoch' if isinstance(val, numpy.ndarray): numpy.set_printoptions(formatter={'all':lambda x: _format_date(x,colkeywords['QuantumUnits'][0])}) out+=numpy.array2string(val,separator=', ') numpy.set_printoptions(formatter=None) else: out+=_format_date(val,colkeywords['QuantumUnits'][0]) elif colkeywords.get('MEASINFO',{}).get('type')=='direction' and singleUnit and val.shape==(1,2): # Format one direction. TODO: extend to array of directions valtype='direction' out+="[" part=quantity(val[0,0],'rad').formatted("TIME",precision=9) part=re.sub(r'(\d+):(\d+):(.*)',r'\1h\2m\3',part) out+=part+", " part=quantity(val[0,1],'rad').formatted("ANGLE",precision=9) part=re.sub(r'(\d+)\.(\d+)\.(.*)',r'\1d\2m\3',part) out+=part+"]" elif isinstance(val, numpy.ndarray) and singleUnit: # Format any array with units valtype='quanta' numpy.set_printoptions(formatter={'all':lambda x: _format_quantum(x, colkeywords['QuantumUnits'][0])}) out+=numpy.array2string(val,separator=', ') numpy.set_printoptions(formatter=None) elif isinstance(val, numpy.ndarray): valtype='other' # Undo quotes around strings numpy.set_printoptions(formatter={'all':lambda x: str(x)}) out+=numpy.array2string(val,separator=', ') numpy.set_printoptions(formatter=None) elif singleUnit: valtype='onequantum' out+=_format_quantum(val, colkeywords['QuantumUnits'][0]) else: valtype='other' out+=str(val) if 'QuantumUnits' in colkeywords and valtype=='other': # Print units if they haven't been taken care of if not (numpy.array(colkeywords['QuantumUnits'])==numpy.array(colkeywords['QuantumUnits'])[0]).all(): # Multiple different units for element in an array. # For now, just print the units and let the user figure out what it means out+=" "+str(colkeywords['QuantumUnits']) else: out+=" "+colkeywords['QuantumUnits'][0] # Numpy sometimes adds double newlines, don't do that out=out.replace('\n\n','\n') return out def _format_row(row, colnames, tab): """ Helper function for _repr_html. Formats one row. :param row: row of this table :param colnames: vector of column names :param tab: table, used to get the column keywords :return: html-formatted row """ out="" out+="\n" for colname in colnames: out+="" out+=_format_cell(row[colname], tab.getcolkeywords(colname)) out+="\n" out+="\n" return out python-casacore-2.2.1/casacore/tables/tableindex.py000066400000000000000000000165731320311315100223400ustar00rootroot00000000000000# tableindex.py: Python tableindex functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: tableindex.py,v 1.6 2006/11/08 00:12:55 gvandiep Exp $ # Make interface to class TableIndexProxy available. from ._tables import TableIndex class tableindex(TableIndex): """The Python interface to Casacore table index. A tableindex makes it possible to find rows in a :class:`table` based on the contents of one or more columns. When constructing the `tableindex` it has to be specified for which column or columns an index has to be built. Those columns will be loaded in memory and thereafter row numbers can be found in a fast way using a binary search. Using a table index is only useful if many searches will be done in the table. For a single or few searches it is better to query the table using method :func:`table.query`. Normally an index will be build on one or more scalar columns (e.g. on ANTENNA1 and ANTENNA2 in a measurementset table). However, it is also possible to buo.d an index for a column containing arrays (e.g. for a column where each cell can contain multiple names. In that case only a single column can be indexed. The index can be unique, but does not need to be. A unique index can be asked for the row number containing a given key. A non-unique index can only be asked for the row numbers containing a key. The returned sequence can thereafter be used in :func:`table.selectrows` to form that subset of the table. `tableindex` supports Python's index operator [] as explained in the methods :func:`rownr` and :func:`rownrs`. """ def __init__(self, table, columnnames, sort=True): TableIndex.__init__(self, table, columnnames, not sort) """Create the index on one or more columns. By default the columns get sorted when forming in the index. By giving `sort=False` this can be omitted in case the table is already in the correct order. Method :func:`table.index` is a somewhat easier way to create a `tableindex` object. """ # Turn a key into a dict if needed. def _makekey(self, key): d = key if not isinstance(d, dict): cols = self.colnames() if len(cols) != 1: raise RuntimeError("key has to be given as a dict for a multi-column index") d = {cols[0]: key} return d def rownr(self, key): """Get the unique row number containing the key. If the index is made from a single column, the keycan be given as a single value. Otherwise the key has to be given as a dict where the name of each field in the dict should correspond with the column name in the index. For example:: t = table('3c343.MS/ANTENNA') tinx = t.index ('NAME') # build index for antenna name rownr = tinx.rownr('RTE') # find an antenna by name rownr = tinx['RTE'] # same as above t.getcell ('POSITION', rownr) # get position of that antenna As shown in the example above the python index operator can also be used to find a row number if the index if made of a single column. An exception will be raised if the index is not unique. In that case method :func:`rownrs` should be used instead. """ return self._rownr(self._makekey(key)) def rownrs(self, key, upperkey={}, lowerincl=True, upperincl=True): """Get a sequence of row numbers containing the key(s). A single key can be given, but by giving argument `upperkey` as well a key range can be given (where upper key must be > lower). One can specify if the lower and upper key should be part of the range (`incl=True`) or not. By default both keys are part of the range. The key and optional upper key have to be given in the same way as for method :func:`rownr`. Similar to method :func:`rownr`. python's index operator [] can be used if the index consists of a single column. However, in this case only key ranges can be used (because the index operator with a single key returns a single row number, thus can only be used for unique indices). The lower key is inclusive, but the upper key is exclusive conform the standard python index semantics. For example:: t = table('3c343.MS') tinx = t.index ('ANTENNA1') # build index for antenna name rownr = tinx.rownr(0) # find antenna1 = 0 rownr = tinx[0:1] # same as above """ lkey = self._makekey(key) ukey = self._makekey(upperkey) if len(ukey) == 0: return self._rownrs(lkey) return self._rownrsrange(lkey, ukey, lowerincl, upperincl) def isunique(self): """Tell if all keys in the index are unique.""" return self._isunique() def colnames(self): """Return the column names the index is made of.""" return self._colnames() def setchanged(self, columnnames=[]): """Tell the index that data has changed. The index is smart enough to detect that the number of rows in the indexed table has changed. However, it cannot detect if a value in a column contained in this inex has changed. So it has to be told explicitly. `columnnames` The names of the columns in which data have changed. Giving no names means that all columns in the index have changed. """ return self._setchanged(columnnames) def __getitem__(self, key): if not isinstance(key, slice): rnr = self.rownr(key) if rnr < 0: raise KeyError("key not found in tableindex") return rnr if key.step is not None: raise RuntimeError("tableindex slicing cannot have a step") lowerkey = 0 if key.start is not None: lowerkey = key.start upperkey = 2147483647; # highest int if key.stop is not None: upperkey = key.stop if (lowerkey >= upperkey): raise RuntimeError("tableindex slice stop must be > start") rnrs = self.rownrs(lowerkey, upperkey, True, False) if len(rnrs) == 0: raise KeyError("keys not found in tableindex") return rnrs python-casacore-2.2.1/casacore/tables/tableiter.py000066400000000000000000000051051320311315100221610ustar00rootroot00000000000000# tableiter.py: Python tableiter functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: tableiter.py,v 1.6 2006/12/11 02:46:08 gvandiep Exp $ # Make interface to class TableIterProxy available. from ._tables import TableIter from .table import table class tableiter(TableIter): """The Python interface to Casacore table iterators A `tableiter` allows iteration through a table based on the contents of one or more columns. Each step in the iteration process forms a subset of the table for which the specified columns have the same value. It can easily be constructed using the :func:`table.iter` method as done in the example below:: t = table('3c343.MS') for ts in t.iter('ANTENNA1'): print ts.nrows() In this example `ts` will be a so-called reference table which can be operated on like any other table object. Multiple column names should be given in a sequence (tuple or list). """ def __init__(self, table, columnnames, order='', sort=True): st = sort if isinstance(sort, bool): st = 'heapsort' if not sort: st = 'nosort' TableIter.__init__(self, table, columnnames, order, st) def __iter__(self): # __iter__ is needed return self def next(self): # next returns a Table object, so turn that into table. return table(self._next(), _oper=3) def reset(self): """Reset the iterator to the beginning.""" self._reset() __next__ = next python-casacore-2.2.1/casacore/tables/tablerow.py000066400000000000000000000131011320311315100220200ustar00rootroot00000000000000# tablerow.py: Python tablerow functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id: tablerow.py,v 1.6 2007/08/28 07:22:18 gvandiep Exp $ # Make interface to class TableRowProxy available. from ._tables import TableRow from .tablehelper import _check_key_slice # A normal tablerow object keeps a reference to a table object to be able # to know the actual number of rows. # However, a mutual dependency is created when doing that for the tablerow # object inside the table object. # Therefore an intermediate _tablerow exists to be used in class table. class _tablerow(TableRow): def __init__(self, table, columnnames, exclude=False): TableRow.__init__(self, table, columnnames, exclude) def iswritable(self): """Tell if all columns in the row object are writable.""" return self._iswritable() def get(self, rownr): """Get the contents of the given row.""" return self._get(rownr) def put(self, rownr, value, matchingfields=True): """Put the values into the given row. The value should be a dict (as returned by method :func:`get`. The names of the fields in the dict should match the names of the columns used in the `tablerow` object. `matchingfields=True` means that the value may contain more fields and only fields matching a column name will be used. """ self._put(rownr, value, matchingfields) def _getitem(self, key, nrows): sei = _check_key_slice(key, nrows, 'tablerow') rownr = sei[0] if len(sei) == 1: return self.get(rownr) result = [] inx = 0 while inx < sei[1]: result.append(self.get(rownr)) rownr += sei[2] inx += 1 return result def _setitem(self, key, value, nrows): sei = _check_key_slice(key, nrows, 'tablerow') rownr = sei[0] if len(sei) == 1: return self.put(rownr, value) if isinstance(value, dict): # The same value is put in all rows. inx = 0 while inx < sei[1]: self.put(rownr, value, True) rownr += sei[2] inx += 1 else: # Each row has its own value. if len(value) != sei[1]: raise RuntimeError("tablerow slice length differs from value length") for val in value: self.put(rownr, val, True) rownr += sei[2] class tablerow(_tablerow): """The Python interface to Casacore table rows. A table row is a record (dict) containing the values of a single row for one or more columns in a table. In constructing the `tablerow` object, one can specify which columns are to be included or excluded. By default all columns will be used, but if the table is writable, only writable columns will be used. A `tablerow` object can easily be constructed using :func:`table.row`. One or more rows can be read or written using the standard python indexing syntax where (negative) strides are possible. For example: t = table ('3c343.MS') tr = t.row (['ANTENNA1', 'ANTENNA2', 'ARRAY_ID']) tr[0] # get row 0 tr[:5] # get row 0,1,2,3,4 tr[-5,-1,] # get last 4 rows tr[-1,-5,-1] # get last 4 rows in reversed order tr[1] = tr[0] # put values of row 0 into row 1 Note that the last line will fail because the table is opened readonly. The argument `readonly=False` is needed in the table constructor to make it work. The `tablerow` class supports the context manager idiom (__enter__ and __exit__). When used in a `with` statement, the table changes will be flushed automatically, which is handy when writing to table rows. For example:: with t.row() as tr: tr.put (1, tr.get(0)) # copy row 0 to row 1 """ def __init__(self, table, columnnames=[], exclude=False): _tablerow.__init__(self, table, columnnames, exclude) self._table = table def __enter__(self): """Function to enter a with block.""" return self def __exit__(self, type, value, traceback): """Function to exit a with block which flushes the table object.""" self._table.flush() def __len__(self): return self._table.nrows() def __getitem__(self, key): return self._getitem(key, self._table.nrows()) def __setitem__(self, key, value): return self._setitem(key, value, self._table.nrows()) python-casacore-2.2.1/casacore/tables/tableutil.py000077500000000000000000000666741320311315100222200ustar00rootroot00000000000000# tableutil.py: Utility table functions # Copyright (C) 2006 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # from collections import defaultdict from casacore import six from .table import table from .tablehelper import _remove_prefix, _value_type_name def tablefromascii(tablename, asciifile, headerfile='', autoheader=False, autoshape=[], columnnames=[], datatypes=[], sep=' ', commentmarker='', firstline=1, lastline=-1, readonly=True, lockoptions='default', ack=True): """Create a table from an ASCII file. Create a table from a file in ASCII format. Columnar data as well as table and column keywords may be specified. Once the table is created from the ASCII data, it is opened in the specified mode and a table object is returned. The table columns are filled from a file containing the data values separated by a separator (one line per table row). The default separator is a blank. Blanks before and after the separator are ignored. If a non-blank separator is used, values can be empty. Such values default to 0, empty string, or F depending on the data type. E.g. 1,,2, has 4 values of which the 2nd and 4th are empty and default to 0. Similarly if fewer values are given than needed, the missing values get the default value. Either the data format can be explicitly specified or it can be found automatically. The former gives more control in ambiguous situations. Both scalar and array columns can be generated from the ASCII input. The format string determines the type and optional shape. It is possible to give the column names and their data types in various ways: - Using 2 header lines (as described below) as the first two lines in the data file or in a separate header file. This is the default way. - Derive them automatically from the data (`autoheader=True`). - Using the arguments `columnnames` and `datatypes` (as non-empty vectors of strings). It implies (`autoheader=False`). The data types should be given in the same way as done in headers. In automatic mode (`autoheader=True`) the first line of the ASCII data is analyzed to deduce the data types. Only the types I, D, and A can be recognized. A number without decimal point or exponent is I (integer), otherwise it is D (double). Any other string is A (string). Note that a number may contain a leading sign (+ or -). The `autoshape` argument can be used to specify if the input should be stored as multiple scalars (the default) or as a single array. In the latter case one axis in the shape can be defined as variable length by giving it the value 0. It means that the actual array shape in a row is determined by the number of values in the corresponding input line. Columns get the names `Column1`, `Column2`, etc.. For example: 1. `autoshape=[]` (which is the default) means that all values are to be stored as scalar columns. 2. `autoshape=0` means that all values in a row are to be stored as a variable length vector. 3. `autoshape=10` defines a fixed length vector. If an input line contains less than 10 values, the vector is filled with default values. If more than 10 values, the latter values are ignored. 4. `autoshape=[5,0]` defines a 2-dim array of which the 2nd axis is variable. Note that if an input line does not contain a multiple of 5 values, the array is filled with default values. If the format of the table is explicitly specified, it has to be done either in the first two lines of the data file (named by the argument filename), or in a separate header file (named by the argument headerfile). In both forms, table keywords may also be specified before the column definitions. The column names and types can be described by two lines: 1. The first line contains the names of the columns. These names may be enclosed in quotes (either single or double). 2. The second line contains the data type and optionally the shape of each column. Valid types are: - S for Short data - I for Integer data - R for Real data - D for Double Precision data - X for Complex data (Real followed by Imaginary) - Z for Complex data (Amplitude then Phase) - DX for Double Precision Complex data (Real followed by Imaginary) - DZ for Double Precision Complex data (Amplitude then Phase) - A for ASCII data (a value must be enclosed in single or double quotes if it contains whitespace) - B for Boolean data (False are empty string, 0, or any string starting with F, f, N, or n). If a column is an array, the shape has to be given after the data type without any whitespace. E.g. `I10` defines an integer vector of length 10. `A2,5` defines a 2-dim string array with shape [2,5]. Note that `I` is not the same as `I1` as the first one defines a scalar and the other one a vector with length 1. The last column can have one variable length axis denoted by the value 0. It "consumes" the remainder of the input line. If the argument headerfile is set then the header information is read from that file instead of the first lines of the data file. To give a simple example of the form where the header information is located at the top of the data file:: COLI COLF COLD COLX COLZ COLS I R D X Z A 1 1.1 1.11 1.12 1.13 1.14 1.15 Str1 10 11 12 13 14 15 16 "" Note that a complex number consists of 2 numbers. Also note that an empty string can be given. Let us now give an example of a separate header file that one might use to get interferometer data into casacore:: U V W TIME ANT1 ANT2 DATA R R R D I I X1,0 The data file would then look like:: 124.011 54560.0 3477.1 43456789.0990 1 2 4.327 -0.1132 34561.0 45629.3 3900.5 43456789.0990 1 3 5.398 0.4521 Note that the DATA column is defined as a 2-dim array of 1 correlation and a variable number of channels, so the actual number of channels is determined by the input. In this example both rows will have 1 channel (note that a complex value contains 2 values). Tables may have keywords in addition to the columns. The keywords are useful for holding information that is global to the entire table (such as author, revision, history, etc.). The keywords in the header definitions must preceed the column descriptions. They must be enclosed between a line that starts with ".key..." and a line that starts with ".endkey..." (where ... can be anything). A table keywordset and column keywordsets can be specified. The latter can be specified by specifying the column name after the .keywords string. Between these two lines each line should contain the following: - The keyword name, e.g., ANYKEY - The datatype and optional shape of the keyword (cf. list of valid types above) - The value or values for the keyword (the keyword may contain a scalar or an array of values). e.g., 3.14159 21.78945 Thus to continue the example above, one might wish to add keywords as follows:: .keywords DATE A "97/1/16" REVISION D 2.01 AUTHOR A "Tim Cornwell" INSTRUMENT A "VLA" .endkeywords .keywords TIME UNIT A "s" .endkeywords U V W TIME ANT1 ANT2 DATA R R R D I I X1,0 Similarly to the column format string, the keyword formats can also contain shape information. The only difference is that if no shape is given, a keyword can have multiple values (making it a vector). It is possible to ignore comment lines in the header and data file by giving the `commentmarker`. It indicates that lines starting with the given marker are ignored. Note that the marker can be a regular expression (e.g. `' *//'` tells that lines starting with // and optionally preceeded by blanks have to be ignored). With the arguments `firstline` and `lastline` one can specify which lines have to be taken from the input file. A negative value means 1 for `firstline` or end-of-file for `lastline`. Note that if the headers and data are combined in one file, these line arguments apply to the whole file. If headers and data are in separate files, these line arguments apply to the data file only. Also note that ignored comment lines are counted, thus are used to determine which lines are in the line range. The number of rows is determined by the number of lines read from the data file. """ import os.path filename = os.path.expandvars(asciifile) filename = os.path.expanduser(filename) if not os.path.exists(filename): s = "File '%s' not found" % (filename) raise IOError(s) if headerfile != '': filename = os.path.expandvars(headerfile) filename = os.path.expanduser(filename) if not os.path.exists(filename): s = "File '%s' not found" % (filename) raise IOError(s) tab = table(asciifile, headerfile, tablename, autoheader, autoshape, sep, commentmarker, firstline, lastline, _columnnames=columnnames, _datatypes=datatypes, _oper=1) six.print_('Input format: [' + tab._getasciiformat() + ']') # Close table and reopen it in correct way. tab = 0 return table(tablename, readonly=readonly, lockoptions=lockoptions, ack=ack) # Create a description of a scalar column def makescacoldesc(columnname, value, datamanagertype='', datamanagergroup='', options=0, maxlen=0, comment='', valuetype='', keywords={}): """Create description of a scalar column. A description for a scalar column can be created from a name for the column and a data value, which is used only to determine the type of the column. Note that a dict value is also possible. It is possible to create the column description in more detail by giving the data manager name, group, option, and comment as well. The data manager type tells which data manager (storage manager) is used to store the columns. The data manager type and group are explained in more detail in the `casacore Tables <../../casacore/doc/html/group__Tables__module.html>`_ documentation. It returns a dict with fields `name` and `desc` which can thereafter be used to build a table description using function :func:`maketabdesc`. `columname` Name of column `value` Example data value used to determine the column's data type. It is only used if argument `valuetype` is not given. `datamanagertype` Type of data manager which can be one of StandardStMan (default) or IncrementalStMan. The latter one can save disk space if many subsequent cells in the column will have the same value. `datamanagergroup` Data manager group. Only for the expert user. `options` Options. Need not be filled in. `maxlen` Maximum length of string values in a column. Default 0 means unlimited. `comment` Comment: informational for user. `valuetype` A string giving the column's data type. Possible data types are bool (or boolean), uchar (or byte), short, int (or integer), uint, float, double, complex, dcomplex, and string. 'keywords' A dict defining initial keywords for the column. For example:: scd1 = makescacoldesc("col2", "")) scd2 = makescacoldesc("col1", 1, "IncrementalStMan") td = maketabdesc([scd1, scd2]) This creates a table description consisting of an integer column `col1`, and a string column `col2`. `col1` uses the IncrementalStMan storage manager, while `col2` uses the default storage manager StandardStMan. """ vtype = valuetype if vtype == '': vtype = _value_type_name(value) rec2 = {'valueType': vtype, 'dataManagerType': datamanagertype, 'dataManagerGroup': datamanagergroup, 'option': options, 'maxlen': maxlen, 'comment': comment, 'keywords': keywords} return {'name': columnname, 'desc': rec2} # Create a description of an array column def makearrcoldesc(columnname, value, ndim=0, shape=[], datamanagertype='', datamanagergroup='', options=0, maxlen=0, comment='', valuetype='', keywords={}): """Create description of an array column. A description for a scalar column can be created from a name for the column and a data value, which is used only to determine the type of the column. Note that a dict value is also possible. It is possible to create the column description in more detail by giving the dimensionality, shape, data manager name, group, option, and comment as well. The data manager type tells which data manager (storage manager) is used to store the columns. The data manager type and group are explained in more detail in the `casacore Tables <../../casacore/doc/html/group__Tables__module.html>`_ documentation. It returns a dict with fields `name` and `desc` which can thereafter be used to build a table description using function :func:`maketabdesc`. `name` The name of the column. `value` A data value, which is only used to determine the data type of the column. It is only used if argument `valuetype` is not given. `ndim` Optionally the number of dimensions. A value > 0 means that all arrays in the column must have that dimensionality. Note that the arrays can still differ in shape unless the shape vector is also given. `shape` An optional sequence of integers giving the shape of the array in each cell. If given, it forces option FixedShape (see below) and sets the number of dimensions (if not given). All arrays in the column get the given shape and the array is created as soon as a row is added. Note that the shape vector gives the shape in each table cell; the number of rows in the table should NOT be part of it. `datamanagertype` Type of data manager which can be one of StandardStMan (default), IncrementalStMan, TiledColumnStMan, TiledCellStMan, or TiledShapeStMan. The tiled storage managers are usually used for bigger data arrays. `datamanagergroup` Data manager group. Only for the expert user. `options` Optionally numeric array options which can be added to combine them. `1` means Direct. It tells that the data are directly stored in the table. Direct forces option FixedShape. If not given, the array is indirect, which means that the data will be stored in a separate file. `4` means FixedShape. This option does not need to be given, because it is enforced if the shape is given. FixedShape means that the shape of the array must be the same in each cell of the column. Otherwise the array shapes may be different in each column cell and is it possible that a cell does not contain an array at all. Note that when given (or implicitly by option Direct), the shape argument must be given as well. Default is 0, thus indirect and variable shaped. `maxlen` Maximum length of string values in a column. Default 0 means unlimited. `comment` Comment: informational for user. `valuetype` A string giving the column's data type. Possible data types are bool (or boolean), uchar (or byte), short, int (or integer), uint, float, double, complex, dcomplex, and string. 'keywords' A dict defining initial keywords for the column. For example:: acd1= makescacoldesc("arr1", 1., 0, [2,3,4]) td = maketabdesc(acd1) This creates a table description consisting of an array column `arr1` containing 3-dim arrays of doubles with shape [2,3,4]. """ vtype = valuetype if vtype == '': vtype = _value_type_name(value) if len(shape) > 0: if ndim <= 0: ndim = len(shape) rec2 = {'valueType': vtype, 'dataManagerType': datamanagertype, 'dataManagerGroup': datamanagergroup, 'ndim': ndim, 'shape': shape, '_c_order': True, 'option': options, 'maxlen': maxlen, 'comment': comment, 'keywords': keywords} return {'name': columnname, 'desc': rec2} # Create a description of a column def makecoldesc(columnname, desc): """Create column description using the description of another column. The other description can be obtained from a table using function :func:`getcoldesc` or from another column description dict using `otherdesc['desc']`. It returns a dict with fields `name` and `desc` which can thereafter be used to build a table description using function :func:`maketabdesc`. `columname` Name of column `desc` Description of the column For example:: cd1 = makecoldesc("col2", t.getcoldesc('othercol')) td = maketabdesc(cd1) This creates a table description consisting of a column `col2` having the same description as column `othercol`. """ return {'name': columnname, 'desc': desc} # Create a table description from a set of column descriptions def maketabdesc(descs=[]): """Create a table description. Creates a table description from a set of column descriptions. The resulting table description can be used in the :class:`table` constructor. For example:: scd1 = makescacoldesc("col2", "aa") scd2 = makescacoldesc("col1", 1, "IncrementalStMan") scd3 = makescacoldesc("colrec1", {}) acd1 = makearrcoldesc("arr1", 1, 0, [2,3,4]) acd2 = makearrcoldesc("arr2", 0.+0j) td = maketabdesc([scd1, scd2, scd3, acd1, acd2]) t = table("mytable", td, nrow=100) | This creates a table description `td` from five column descriptions and then creates a 100-row table called `mytable` from the table description. | The columns contain respectivily strings, integer scalars, records, 3D integer arrays with fixed shape [2,3,4], and complex arrays with variable shape. """ rec = {} # If a single dict is given, make a list of it. if isinstance(descs, dict): descs = [descs] for desc in descs: colname = desc['name'] if colname in rec: raise ValueError('Column name ' + colname + ' multiply used in table description') rec[colname] = desc['desc'] return rec def makedminfo(tabdesc, group_spec=None): """Creates a data manager information object. Create a data manager information dictionary outline from a table description. The resulting dictionary is a bare outline and is available for the purposes of further customising the data manager via the `group_spec` argument. The resulting dictionary can be used in the :class:`table` constructor and the :meth:`default_ms` and :meth:`default_ms_subtable` functions. `tabdesc` The table description `group_spec` The SPEC for a data manager group. In practice this is useful for setting the Default Tile Size and Maximum Cache Size for the Data Manager { 'WeightColumnGroup' : { 'DEFAULTTILESHAPE': np.int32([4,4,4]), 'MAXIMUMCACHESIZE': 1000, } } This should be used with care. """ if group_spec is None: group_spec = {} class DMGroup(object): """ Keep track of the columns, type and spec of each data manager group """ def __init__(self): self.columns = [] self.type = None self.spec = None dm_groups = defaultdict(DMGroup) # Iterate through the table columns, grouping them # by their dataManagerGroup for c, d in six.iteritems(tabdesc): if c in ('_define_hypercolumn_', '_keywords_', '_private_keywords_'): continue # Extract group and data manager type group = d.get("dataManagerGroup", "StandardStMan") type_ = d.get("dataManagerType", "StandardStMan") # Set defaults if necessary if not group: group = "StandardStMan" if not type_: type_ = "StandardStMan" # Obtain the (possibly empty) data manager group dm_group = dm_groups[group] # Add the column dm_group.columns.append(c) # Set the spec if dm_group.spec is None: dm_group.spec = group_spec.get(group, {}) # Check that the data manager type is consistent across columns if dm_group.type is None: dm_group.type = type_ elif not dm_group.type == type_: raise ValueError("Mismatched dataManagerType '%s' " "for dataManagerGroup '%s' " "Previously, the type was '%s'" % (type_, group, dm_group.type)) # Output a data manager entry return { '*%d'%(i+1): { 'COLUMNS': dm_group.columns, 'TYPE': dm_group.type, 'NAME': group, 'SPEC' : dm_group.spec, 'SEQNR': i } for i, (group, dm_group) in enumerate(six.iteritems(dm_groups)) } # Create the old glish names for them. tablecreatescalarcoldesc = makescacoldesc tablecreatearraycoldesc = makearrcoldesc tablecreatedesc = maketabdesc tablecreatedm = makedminfo # Define a hypercolumn in the table description. def tabledefinehypercolumn(tabdesc, name, ndim, datacolumns, coordcolumns=False, idcolumns=False): """Add a hypercolumn to a table description. It defines a hypercolumn and adds it the given table description. A hypercolumn is an entity used by the Tiled Storage Managers (TSM). It defines which columns have to be stored together with a TSM. It should only be used by expert users who want to use a TSM to its full extent. For a basic TSM s hypercolumn definition is not needed. tabledesc A table description (result from :func:`maketabdesc`). name Name of hypercolumn ndim Dimensionality of hypercolumn; normally 1 more than the dimensionality of the arrays in the data columns to be stored with the TSM datacolumns Data columns to be stored with TSM coordcolumns Optional coordinate columns to be stored with TSM idcolumns Optional id columns to be stored with TSM For example:: scd1 = makescacoldesc("col2", "aa") scd2 = makescacoldesc("col1", 1, "IncrementalStMan") scd3 = makescacoldesc("colrec1", {}) acd1 = makearrcoldesc("arr1", 1, 0, [2,3,4]) acd2 = makearrcoldesc("arr2", as_complex(0)) td = maketabdesc([scd1, scd2, scd3, acd1, acd2]) tabledefinehypercolumn(td, "TiledArray", 4, ["arr1"]) tab = table("mytable", tabledesc=td, nrow=100) | This creates a table description `td` from five column descriptions and then creates a 100-row table called mytable from the table description. | The columns contain respectivily strings, integer scalars, records, 3D integer arrays with fixed shape [2,3,4], and complex arrays with variable shape. | The first array is stored with the Tiled Storage Manager (in this case the TiledColumnStMan). """ rec = {'HCndim': ndim, 'HCdatanames': datacolumns} if not isinstance(coordcolumns, bool): rec['HCcoordnames'] = coordcolumns if not isinstance(idcolumns, bool): rec['HCidnames'] = idcolumns if '_define_hypercolumn_' not in tabdesc: tabdesc['_define_hypercolumn_'] = {} tabdesc['_define_hypercolumn_'][name] = rec def tabledelete(tablename, checksubtables=False, ack=True): """Delete a table on disk. It is the same as :func:`table.delete`, but without the need to open the table first. """ tabname = _remove_prefix(tablename) t = table(tabname, ack=False) if t.ismultiused(checksubtables): six.print_('Table', tabname, 'cannot be deleted; it is still in use') else: t = 0 table(tabname, readonly=False, _delete=True, ack=False) if ack: six.print_('Table', tabname, 'has been deleted') def tableexists(tablename): """Test if a table exists.""" result = True try: t = table(tablename, ack=False) except: result = False return result def tableiswritable(tablename): """Test if a table is writable.""" result = True try: t = table(tablename, readonly=False, ack=False) result = t.iswritable() except: result = False return result def tablecopy(tablename, newtablename, deep=False, valuecopy=False, dminfo={}, endian='aipsrc', memorytable=False, copynorows=False): """Copy a table. It is the same as :func:`table.copy`, but without the need to open the table first. """ t = table(tablename, ack=False) return t.copy(newtablename, deep=deep, valuecopy=valuecopy, dminfo=dminfo, endian=endian, memorytable=memorytable, copynorows=copynorows) def tablerename(tablename, newtablename): """Rename a table. The table with the given name is renamed (or moved) to the new name. """ t = table(tablename, ack=False) t.rename(newtablename) def tableinfo(tablename): """Get type info of a table. It is the same as :func:`table.info`, but without the need to open the table first. """ t = table(tablename, ack=False) return t.info() def tablesummary(tablename): """Get the summary of a table. It is the same as :func:`table.summary`, but without the need to open the table first. """ t = table(tablename, ack=False) t.summary() def tablestructure(tablename, dataman=True, column=True, subtable=False, sort=False): """Print the structure of a table. It is the same as :func:`table.showstructure`, but without the need to open the table first. """ t = table(tablename, ack=False) six.print_(t.showstructure(dataman, column, subtable, sort)) python-casacore-2.2.1/casacore/tables/wxtablebrowser.py000077500000000000000000000066171320311315100232740ustar00rootroot00000000000000from wxPython.grid import * from wxPython.wx import * from casacore import six class wxCasaTable(wxPyGridTableBase): """ This is all it takes to make a custom data table to plug into a wxGrid. There are many more methods that can be overridden, but the ones shown below are the required ones. This table simply provides strings containing the row and column values. """ def __init__(self, log, ctable): wxPyGridTableBase.__init__(self) self.log = log self.casatab = ctable self.odd = wxGridCellAttr() self.odd.SetBackgroundColour("gray90") self.even = wxGridCellAttr() self.even.SetBackgroundColour("white") def GetAttr(self, row, col, kind): attr = [self.even, self.odd][row % 2] attr.IncRef() return attr def GetColLabelValue(self, col): colnames = self.casatab.colnames() return colnames[col] def GetNumberRows(self): return self.casatab.nrows() def GetNumberCols(self): return self.casatab.ncols() def IsEmptyCell(self, row, col): return False def GetValue(self, row, col): coln = self.casatab.colnames() cell = 'array' ## if self.casatab.isscalarcol(coln[col]): ## cellval = self.casatab.getcell(coln[col],row) ## if isinstance(cellval,float): ## if coln[col] == "TIME": ## cell = str(cellval) ## else: ## cell = "%3.5f" % cellval ## else: ## cell = str(cellval) ## else: ## cell += self.casatab.getcolshapestring(coln[col],row,1)[0] ## return cell return str(self.casatab.getcell(coln[col], row)) def SetValue(self, row, col, value): self.log.write('SetValue(%d, %d, "%s") ignored.\n' % (row, col, value)) # --------------------------------------------------------------------------- class wxCasaTableGrid(wxGrid): def __init__(self, parent, log, ctable): wxGrid.__init__(self, parent, -1) table = wxCasaTable(log, ctable) # The second parameter means that the grid is to take ownership of the # table and will destroy it when done. Otherwise you would need to keep # a reference to it and call it's Destroy method later. self.SetTable(table, True) EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) # added def OnRightDown(self, event): # added six.print_(self.GetSelectedRows()) # added # --------------------------------------------------------------------------- class CasaTestFrame(wxFrame): def __init__(self, parent, log, ctable): wxFrame.__init__(self, parent, -1, "Casa Table Browser", size=(640, 480)) grid = wxCasaTableGrid(self, log, ctable) grid.EnableEditing(False) # grid.AutoSizeColumns() # --------------------------------------------------------------------------- if __name__ == '__main__': import sys app = wxPySimpleApp() from casacore.tables import table as casatable casatab = casatable('/nfs/aips++/data/atnf/scripts/C972.ms') frame = CasaTestFrame(None, sys.stdout, casatab) frame.Show(True) app.MainLoop() # --------------------------------------------------------------------------- python-casacore-2.2.1/casacore/util/000077500000000000000000000000001320311315100173365ustar00rootroot00000000000000python-casacore-2.2.1/casacore/util/__init__.py000066400000000000000000000001431320311315100214450ustar00rootroot00000000000000""" Utilities for casacore modules. """ from .substitute import substitute, getlocals, getvariable python-casacore-2.2.1/casacore/util/substitute.py000066400000000000000000000233431320311315100221300ustar00rootroot00000000000000# substitute.py: substitute python variables and expressions # Copyright (C) 1998,1999,2008 # Associated Universities, Inc. Washington DC, USA. # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. # # Correspondence concerning AIPS++ should be addressed as follows: # Internet email: aips2-request@nrao.edu. # Postal address: AIPS++ Project Office # National Radio Astronomy Observatory # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # # $Id$ import numpy as np __all__ = ['getlocals', 'getvariable', 'substitute'] def getlocals(back=2): """Get the local variables some levels back (-1 is top).""" import inspect fr = inspect.currentframe() try: while fr and back != 0: fr1 = fr fr = fr.f_back back -= 1 except: pass return fr1.f_locals def getvariable(name): """Get the value of a local variable somewhere in the call stack.""" import inspect fr = inspect.currentframe() try: while fr: fr = fr.f_back vars = fr.f_locals if name in vars: return vars[name] except: pass return None def substitute(s, objlist=(), globals={}, locals={}): """Substitute global python variables in a command string. This function parses a string and tries to substitute parts like `$name` by their value. It is uses by :mod:`image` and :mod:`table` to handle image and table objects in a command, but also other variables (integers, strings, etc.) can be substituted. The following rules apply: 1. A name must start with an underscore or alphabetic, followed by zero or more alphanumerics and underscores. 2. String parts enclosed in single or double quotes are literals and are left untouched. Furthermore a $ can be escaped by a backslash, which is useful if an environment variable is used. Note that an extra backslash is required in Python to escape the backslash. The output contains the quotes and backslashes. 3. A variable is looked up in the given local and global namespaces. 4. If the variable `name` has a vector value, its substitution is enclosed in square brackets and separated by commas. 5. A string value is enclosed in double quotes. If the value contains a double quote, that quote is enclosed in single quotes. 6. If the name's value has a type mentioned in the argument `objlist`, it is substituted by `$n` (where n is a sequence number) and its value is added to the objects of that type in `objlist`. 7. If the name is unknown or has an unknown type, it is left untouched. The `objlist` argument is a list of tuples or lists where each tuple or list has three fields: 1. The first field is the object type (e.g. `table`) 2. The second field is a prefix for the sequence number (usually empty). E.g. regions could have prefix 'r' resulting in a substitution like `$r1`. 3. The third field is a list of objects to be substituted. New objects get appended to it. Usually the list is initially empty. Apart from substituting variables, it also substitutes `$(expression)` by the expression result. It correctly handles parentheses and quotes in the expression. For example:: >>> a = 2 >>> b = 3 >>> substitute('$(a+b)+$a') '5+2' >>> substitute('$(a+b+a)') '7' >>> substitute('$((a+b)+$a)') '$((a+b)+$a)' >>> substitute('$((a+b)*(a+b))') '25' >>> substitute('$(len("ab cd( de"))') '9' Substitution is NOT recursive. E.g. if a=1 and b="$a", the result of substitute("$b") is "$a" and not 1. """ # Get the local variables at the caller level if not given. if not locals: locals = getlocals(3) # Initialize some variables. backslash = False dollar = False nparen = 0 name = '' evalstr = '' squote = False dquote = False out = '' # Loop through the entire string. for tmp in s: if backslash: out += tmp backslash = False continue # If a dollar is found, we might have a name or expression. # Alphabetics and underscore are always part of name. if dollar and nparen == 0: if tmp == '_' or ('a' <= tmp <= 'z') or ('A' <= tmp <= 'Z'): name += tmp continue # Numerics are only part if not first character. if '0' <= tmp <= '9' and name != '': name += tmp continue # $( indicates the start of an expression to evaluate. if tmp == '(' and name == '': nparen = 1 evalstr = '' continue # End of name found. Try to substitute. out += substitutename(name, objlist, globals, locals) dollar = False # Handle possible single or double quotes. if tmp == '"' and not squote: dquote = not dquote elif tmp == "'" and not dquote: squote = not squote if not dquote and not squote: # Count the number of balanced parentheses # (outside quoted strings) in the subexpression. if nparen > 0: if tmp == '(': nparen += 1 elif tmp == ')': nparen -= 1 if nparen == 0: # The last closing parenthese is found. # Evaluate the subexpression. # Add the result to the output. out += substituteexpr(evalstr, globals, locals) dollar = False evalstr += tmp continue # Set a switch if we have a dollar (outside quoted # and eval strings). if tmp == '$': dollar = True name = '' continue # No special character; add it to output or evalstr. # Set a switch if we have a backslash. if nparen == 0: out += tmp else: evalstr += tmp if tmp == '\\': backslash = True # The entire string has been handled. # Substitute a possible last name. # Insert a possible incomplete eval string as such. if dollar: out += substitutename(name, objlist, globals, locals) else: if nparen > 0: out += '$(' + evalstr return out # This function tries to substitute the given name using # the rules described in the description of function substitute. def substitutename(name, objlist, globals, locals): # If the name is empty, return a single dollar. if len(name) == 0: return '$' # First try as a single variable; otherwise as an expression. try: v = getvariable(name) if v is None: v = eval(name, globals, locals) except NameError: return '$' + name # See if the resulting value is one of the given special types. try: for objtype, objstr, objs in objlist: if isinstance(v, objtype): objs += [v] return '$' + objstr + str(len(objs)) except: pass # No specific type, thus a normal value has to be substituted. return substitutevar(v) # This function tries to substitute the given name using # the rules described in the description of function substitute. def substituteexpr(expr, globals={}, locals={}): try: res = eval(expr, globals, locals) v = substitutevar(res) except: # If the expr is undefined, return the original. v = '$(' + expr + ')' return str(v) # Substitute a value. def substitutevar(v): out = '' if isinstance(v, tuple) or isinstance(v, list) or isinstance(v, np.ndarray): out = '[' first = True for tmp in v: if first: first = False else: out += ',' out += substituteonevar(tmp) out += ']' else: out = substituteonevar(v) return out def substituteonevar(v): # A string needs to be enclosed in quotes. # A vector value is enclosed in square brackets and separated by commas. if isinstance(v, str): return substitutestring(v) # A numeric or boolean value is converted to a string. # A vector value is enclosed in square brackets and separated by commas. # Take care we have enough precision. if isinstance(v, bool): if v: return 'T' return 'F' return str(v) # Enclose a string in double quotes. # If the string contains double quotes, enclose them in single quotes. # E.g. ab"cd # is returned as "ab"'"'"cd" # which is according to the TaQL rules for strings. def substitutestring(value): out = '"' for tmp in value: if tmp == '"': out += '"' + "'" + '"' + "'" + '"' else: out += tmp return out + '"' python-casacore-2.2.1/doc/000077500000000000000000000000001320311315100153465ustar00rootroot00000000000000python-casacore-2.2.1/doc/199.html000066400000000000000000016000541320311315100165640ustar00rootroot00000000000000 NOTE 199 – Table Query Language

NOTE 199 – Table Query Language

Ger van Diepen, ASTRON Dwingeloo

2016 Apr 4

Abstract

The Table Query Language (TaQL) is an SQL-like high level language to do operations like selection, sort, and update on a casacore table. It is a very versatile language with full support for table columns containing array data. It has inherent support for masked arrays, units, and astronomical coordinates. It has a very rich set of functions (like cone search and array reduction) making it very suitable for astronomical applications. User deï¬ned functions can be added easily. It also has full support of grouping/aggregation and nested queries. An operation that can be expressed in a single function is the matching of two sky catalogues.
It can be used from C++, Python, and any shell.

1.01997 Feb 9 Original version
2.0 2010 Nov 5UPDATE, INSERT, DELETE and COUNT commands
3.0 2015 Jul 29GROUPBY and HAVING clause
3.1 2016 Apr 4 Masked arrays; ALTER TABLE and SHOW commands

A pdf version of this note is available.

Contents

1 Introduction
 1.1 TaQL vs SQL
2 TaQL Commands
 2.1 Command summary
 2.2 Using a style
  2.2.1 UDF library synonyms
  2.2.2 Tracing
  2.2.3 Timing
 2.3 Reserved words
3 Selection from a table
 3.1 SELECT command overview
  3.1.1 Column/keyword lookup
 3.2 SELECT column_list
  3.2.1 Masked array in column_list
 3.3 INTO [table] [AS options]
 3.4 FROM table_list
 3.5 WHERE expression
 3.6 GROUPBY group_list
 3.7 HAVING expression
 3.8 ORDERBY sort_list
 3.9 LIMIT/OFFSET expression
 3.10 GIVING [table] [AS options] — set
4 Expressions
 4.1 Data Types
 4.2 Regular Expressions and String Distances
 4.3 Constants
  4.3.1 Bool
  4.3.2 Integer
  4.3.3 Double (and time/position)
  4.3.4 Complex
  4.3.5 String
  4.3.6 Regular expression and String distance
  4.3.7 Date/time
  4.3.8 Arrays
  4.3.9 Masked Arrays
  4.3.10 Null Arrays
 4.4 Table Columns
  4.4.1 Referring to SELECT columns
 4.5 Table Keywords
 4.6 Operators
 4.7 Sets and intervals
 4.8 Array Index Operator
 4.9 Units
 4.10 Functions
  4.10.1 String functions
  4.10.2 Regex functions
  4.10.3 Date/time functions
  4.10.4 Pretty printing functions
  4.10.5 Comparison functions
  4.10.6 Mathematical functions
  4.10.7 Array to scalar reduce functions
  4.10.8 Array to array reduce functions
  4.10.9 Array downsampling functions
  4.10.10 Array functions operating in running windows
  4.10.11 Type conversion functions
  4.10.12 Array creation functions
  4.10.13 Aggregate functions
  4.10.14 Miscellaneous functions
  4.10.15 Cone search functions
  4.10.16 User deï¬ned functions
  4.10.17 Special MeasurementSet functions
  4.10.18 Special Measures functions
 4.11 Subqueries
5 Aggregation, GROUPBY, HAVING
 5.1 Aggregation and GROUPBY
 5.2 HAVING
6 Some further remarks
 6.1 Joining tables
  6.1.1 Join on row number
  6.1.2 Join using an indexed subquery
  6.1.3 Join using a subquery set
  6.1.4 Join using derivedmscal
 6.2 Optimization
7 Modifying a table
 7.1 UPDATE
  7.1.1 Partial Array Update
  7.1.2 Update columns from a masked array
 7.2 INSERT
 7.3 DELETE
8 Creating a new table
 8.1 Column speciï¬cation
 8.2 Data manager speciï¬cation
9 Modifying the table structure
 9.1 ADD COLUMN
 9.2 RENAME COLUMN
 9.3 DELETE COLUMN
 9.4 SET KEYWORD
 9.5 COPY KEYWORD
 9.6 RENAME KEYWORD
 9.7 DELETE KEYWORD
 9.8 ADD ROW
10 Counting in a table
11 Calculations on a table
12 Examples
 12.1 Selection examples
  12.1.1 Reference table results
  12.1.2 Plain table results
 12.2 Modiï¬cation examples
  12.2.1 Applying running median to an image
 12.3 Table creation examples
 12.4 Calculation examples
 12.5 Aggregation/groupby examples
  12.5.1 Obtaining the flux density from visibility data
  12.5.2 Number of fully flagged baselines per antenna
13 Interface to TaQL
 13.1 Python interface python-casacore
 13.2 Interface to Glish
 13.3 Program taql
 13.4 C++ interface
  13.4.1 TaQL query string
  13.4.2 Expression string
  13.4.3 Expression classes
14 Writing user deï¬ned functions
 14.1 UDFs in Python
15 Possible future developments

1 Introduction

The Table Query Language (TaQL, rhymes with bagel (though some people pronounce it as tackle)) is a language for querying and manipulating data in Casacore tables. It makes it possible to get results or select rows from an arbitrary table based on the contents of its columns and keywords. It supports arbitrary complex expressions including units, extended regular expressions, and many functions. User deï¬ned functions written in C++ or Python are supported. TaQL also makes sorting and column selection possible. Furthermore TaQL has commands to update, add or delete rows and columns in a table and to create a new table.

The ï¬rst sections of this document explain the syntax and show the options. The last sections give several examples and show the interface to TaQL using Python or C++. The Python interface makes it possible to embed Python variables and expressions in a TaQL command.

1.1 TaQL vs SQL

TaQL is modeled after SQL and contains a subset of SQL’s functionality. Some familiarity with SQL makes it easier to understand the TaQL syntax. The most important features of TaQL different from SQL are:

  • The result of a SELECT is another table (either temporary or persistent). Usually this is a so-called reference table, but it is also possible to make a deep copy and create a plain table.
    A reference table is a table that can be used as any other table, but does not contain data. Instead it contains references to the rows and columns in the original table. Thus modifying data in a reference table means that effectively the data in the original table are modiï¬ed.
  • A very rich set of mathematical and other functions.
  • Any operand can be a scalar or an N-dimensional array. Many reduce functions can be applied to arrays.
  • Arrays can optionally be masked.
  • Full support of units and automatic conversion of units.
  • Support of various types of patterns/regular expressions and support of maximum string distance (Levensthein (aka Edit) distance).
  • Speciï¬c operators and functions for cone searching (i.e., spatial searching with a search radius).
  • An advanced way of specifying intervals.
  • No support of indices, thus a linear table search is done. Because data are stored column-wise, a linear search is usually very fast, even for very large tables.
  • Limited support for joins (only implicit joins on row number).
  • Many aggregate functions.
  • The COUNT command exists to count the occurrences of column values. Although it can still be used, this command is obsolete now GROUPBY is fully supported.
  • The CALC command exists to calculate an arbitrary expression (including subqueries) on a table. This can be useful to derive values from a table (e.g., the number of flags set in a measurement set). It can even be used as a desk calculator.
  • TaQL can be used from languages with different conventions, for example the order of array axes. Therefore it is possible to set the language style to be used.
  • The language can be extended by means of User Deï¬ned Functions, possibly implemented in Python. Some standard UDFs exist to deal with MeasurementSets and to do measure conversions (for directions, epochs, positions, and stokes).

TaQL has a keyword that makes it possible to time the various parts of a TaQL command.

2 TaQL Commands

2.1 Command summary

TaQL contains several commands. In the commands shown below the square brackets are not part of the syntax, but indicate the optional parts of the commands.

  • show (or help)
      SHOW [type ...]

    can be used to give some TaQL explanation or to show table information. A sole show command shows the possible options. HELP is a synonym for SHOW.

  • selection
      SELECT [[DISTINCT] expression_list]  
        [INTO table [AS options]]  
        [FROM table_list]  
        [WHERE expression]  
        [GROUPBY expression_list]  
        [HAVING expression]  
        [ORDERBY [DISTINCT] sort_list]  
        [LIMIT expression] [OFFSET expression]  
        [GIVING table [AS options] | set]  
        [DMINFO datamanagers]

    It can be used to get an optionally sorted subset from a table. It can also be used to do a subquery (see section 4.11 for more information on subqueries).

  • updating
      UPDATE table_list SET update_list [FROM table_list]  
        [WHERE ...] [ORDERBY ...] [LIMIT ...] [OFFSET ...]

    It can be used to update data in (a subset of) the ï¬rst table in the ï¬rst table list.

  • addition
      INSERT INTO table_list SET column=expr, column=expr, ...  
    or  
      INSERT INTO table_list [(column_list)] VALUES (expr_list)  
    or  
      INSERT INTO table_list [(column_list)] SELECT_command

    It can be used to add and ï¬ll new rows in the ï¬rst table in the table list.

  • deletion
      DELETE FROM table_list  
        [WHERE ...] [ORDERBY ...] [LIMIT ...] [OFFSET ...]

    It can be used to delete some or all rows from the ï¬rst table in the table list.

  • counting
      COUNT [column_list] FROM table_list [WHERE ...]

    It can be used to count occurrences of column values. Although the command can still be used, it is basically obsolete because the same (and more) can be achieved with the GROUPBY clause and aggregate functions in the SELECT command.
    Furthermore, usually GROUPBY is faster.

  • calculation
      CALC expression [FROM table_list]

    It can be used to calculate an expression, in which columns in a table can be used.

  • table creation
      CREATE TABLE table [AS options]  
        [column_spec]  
        [LIMIT ...]  
        [DMINFO datamanagers]

    It can be used to create a new table with the given columns and number of rows. Optionally speciï¬c table and data manager info can be given.

  • table structure modiï¬cation
      ALTER TABLE table  
        [ADD COLUMN [column_spec] [DMINFO datamanagers]  
        [RENAME COLUMN column_pair_list]  
        [DROP COLUMN column_list]  
        [SET KEYWORD key=value, key=value, ...]  
        [COPY KEYWORD key=other, key=other, ...]  
        [RENAME KEYWORD keyword_pair_list]  
        [DROP KEYWORD keyword_list]  
        [ADD ROW nrow]

    It can be used to add, rename, and remove columns and keywords and to add rows. Multiple such subcommands can be given, separated by white space.

The commands and verbs in the commands are case-insensitive, but case is important in string values and in names of columns and keywords. Whitespace (blanks and tabs) can be used at will.
Section 7 (Modifying a table) explains the UPDATE, INSERT, and DELETE commands in more detail. The CREATE TABLE command is explained in section 8 (Creating a table). The ALTER TABLE command is explained in section 9 (Modifying the table structure).
Section 10 (Counting in a table) explains the COUNT command in more detail.
Section 11 (Calculations on a table) explains the CALC command in more detail.

2.2 Using a style

TaQL can be used from different languages, in particular Python and Glish. Each has its own conventions breaking down into three important categories:

  • 0-based or 1-based indexing.
  • Fortran-order or C-order of arrays.
  • Inclusive or exclusive end in start:end ranges.

The user can set the style (convention) to be used by preceding a TaQL statement with

  USING STYLE value, value, ...

The possible (case-independent) values are:

  • BASE0 or BASE1 telling the indexing style.
  • ENDEXCL or ENDINCL telling the range style.
  • CORDER or FORTRANORDER telling the array style.
  • PYTHON which is equivalent to BASE0,ENDEXCL,CORDER
  • GLISH which is equivalent to BASE1,ENDINCL,FORTRANORDER

The following values are also possible and are described in the next subsections.

  • synonym=libname to deï¬ne a synonym for a user deï¬ned library.
  • TRACE or NOTRACE to (un)set tracing.
  • TIME or NOTIME to (un)set timing.

If multiple values are given for a category, the last one will be used. The default style used is GLISH, which is the way TaQL always worked before this feature was introduced.

It is important to note that the interpretation of the axes numbers depends on the style being used. e.g., when using glish style, axes numbers are 1-based and in Fortran order, thus axis 1 is the most rapidly varying axis. When using python style, axis 0 is the most slowly varying axis.
Casacore arrays are in Fortran order, but TaQL maps it to the style being used. Thus when using python style, the axes will be reversed (data will not be transposed). Note: unless said differently, all examples in this document are done using the Python style.

The style feature has to be used with care. A given TaQL statement will behave differently if used with another style.

2.2.1 UDF library synonyms

The style clause can also be used to deï¬ne synonyms for the library names of user deï¬ned functions. For example:

  using style mscal=derivedmscal

deï¬nes the synonym mscal. Synonyms make it easier (i.e., less typing) to specify user deï¬ned functions.
Note that the synonym in the example above is automatically deï¬ned by TaQL as well as the synonym py for pytaql.

2.2.2 Tracing

It is possible to get tracing output during the execution of a TaQL command by using the case-insensitive value TRACE in the using style command.

2.2.3 Timing

It is possible to time a TaQL command by using the case-insensitive value TIME in the using style command. For historical reasons it is also possible to use the the case-insensitive keyword TIME before or after the optional style command.

Timing shows the total execution time and the times needed for various parts of the TaQL command on stdout. For example:

time select distinct ANTENNA1,ANTENNA2  
from ~/3C343.MS where any(FLAG)’  
 
  Where          2.87 real    2.16 user    0.69 system  
  Projection        0 real       0 user       0 system  
  Distinct       0.18 real    0.16 user    0.03 system  
 Total time      3.07 real    2.33 user    0.72 system

shows the time to do the where part (i.e., row selection on FLAG), projection (selection of columns), and distinct (unique column values).

2.3 Reserved words

TaQL uses the following words as part of its language.

  ALL           AND      AS        ASC  
  BETWEEN  
  CALC          CREATETABLE  
  DELETE        DESC     DISTINCT  DMINFO  
  EXCEPT        EXISTS  
  F             FALSE    FROM  
  GIVING        GROUPBY  GROUPBYROLLUP  
  HAVING  
  IN            INCONE   INSERT    INTERSECT  INTO  
  JOIN  
  LIKE          LIMIT  
  MINUS  
  NODUPLICATES  NOT  
  OFFSET        ON       OR        ORDERBY  
  SAVETO        SELECT   SET       SUBTABLES  
  T             TO       TOP       TRUE  
  UNION         UNIQUE   UPDATE    USINGSTYLE  
  VALUES  
  WHERE  
  XOR

These words are reserved. Note that the words in the TaQL vocabulary are case insensitive, thus the lowercase (or any mixed case) versions are also reserved.

The reserved words cannot directly be used as column name, keyword name, or unit. However, a reserved word can be used that way by escaping it with a backslash like \AS. When reading further, the meaning of

     \IN  \in  IN [3mm,4mm]  
   column unit IN    set

might become clear. It means: use unit in (inch) for column IN and test if it is in the given set.
Note this is unlike SQL where quotes have to be used to use a reserved word as a column name.

3 Selection from a table

The SELECT is the main TaQL command. It can be used to select a subset of rows and/or columns from a table and to generate new columns based on expressions.

As explained above, the result of a selection is usually a reference table. This table can be used as any other table, thus it is possible to do another selection on it or to update it (which updates the underlying original table). It is, however, not possible to insert rows in a reference table or to delete rows from it.

If the select column list contains expressions, it is not possible to generate a reference table. Instead a normal plain table is generated (which can take some time if it contains large data arrays). It should be clear that updating such a table does not update the original table.

The FROM clause can be omitted from the select. In that case no columns can be used in the selection, but functions like rand and rowid make variable output possible. Clauses like ORDERBY can be given. The GIVING (or INTO) might be useful to store the result in a table.

There is no explicit JOIN clause, but it is possible to equi-join tables on row number. Such tables must have the same number of rows. One can also join , for example, the main table of a MeasurementSet with a subtable like the ANTENNA table using a subquery. Joins are explained further in section 6.1.

3.1 SELECT command overview

The SELECT command consists of various clauses of which most are optional. The full command looks as follows where the optional parts are shown in square brackets.

  SELECT [[DISTINCT] column_list]  
    [INTO table [AS options]]  
    [FROM table_list]  
    [WHERE expression]  
    [GROUPBY expression_list]  
    [HAVING expression]  
    [ORDERBY [DISTINCT] sort_list]  
    [LIMIT expression] [OFFSET expression]  
    [GIVING table [AS options] | set]  
    [DMINFO datamanagers]

The clauses are executed in a somewhat different order.

  1. FROM to deï¬ne the tables to be used.
  2. WHERE to select the rows.
  3. GROUPBY to group selected rows.
  4. SELECT to ï¬ll select columns used in HAVING or ORDERBY
  5. HAVING to select groups.
  6. SELECT to ï¬ll the remaining select columns.
  7. ORDERBY to sort the result.
  8. LIMIT (or TOP) and OFFSET to ignore entries in the sorted result.
  9. DMINFO to deï¬ne the data managers to be used if the result is
  10. GIVING/INTO to store the ï¬nal result. stored in a plain table. See section 8.2 how to specify them.

All clauses are explained in full detail in the subsequent sections.

3.1.1 Column/keyword lookup

Expressions in the various clauses will normally use column names to select, sort, or group a table. It is also possible to use table keywords or column keywords by giving their names. Furthermore, it is possible to use a column, created in the SELECT clause, in the HAVING and ORDERBY clauses. This can save time in both specifying and executing the command, because a possibly complicated expression can be used to create such a column. If such columns are used, that part of the SELECT is executed before HAVING.

TaQL uses the following lookup scheme for column/keyword names.

  1. If preceded by a shorthand (like in t0.DATA), the name is looked up in the corresponding table.
  2. If not preceded by a shorthand, a name is ï¬rst looked up in the select columns. If not found, the name is looked up in the ï¬rst table given in FROM.
  3. A name is ï¬rst looked up as a column in a table. If not found, it is looked up as a table keyword.

See the discussion of column names and keyword names for more details.

3.2 SELECT column_list

Columns to be selected can be given as a comma-separated list with names of columns that have to be selected from the tables in the table_list (see below). If no column_list is given, all columns of the ï¬rst table will be selected. It results in a so-called reference table. Optionally a selected column can be given another name in the reference table using AS name (where AS is optional). For example:

  select TIME,ANTENNA1,ANTENNA2,DATA from 3C343.MS  
  select TIME,ANTENNA1,ANTENNA2,MODEL_DATA AS DATA from 3C343.MS

It is possible to precede a column name with a table shorthand indicating with table in the FROM clause has to be used. If not given, a column will be looked up in the ï¬rst table. Note that if equally named columns from different tables are used, one has to get a new name, otherwise a ’duplicate name’ error will occur. For example:

  select t0.DATA, t1.DATA as DATA1 from 3C343.MS t0, 3C343_1.MS t1

Apart from giving exact column names, it is also possible to use wildcards by means of a UNIX ï¬lename-like pattern (like p/pattern/) or a regular expression (like f/regex/ for a full match or m/regex/ for a partial match). They can be suffixed with an i indicating case-insensitive matching. See section 4.3.6 for a discussion of these constants. The operator ~ needs to be given before the pattern or regex to indicate that columns have to be included. Thereafter operator !~ can be used with another pattern or regex to remove columns. Such an excluding pattern or regex only removes columns from the wildcarded columns before it until the latest non-wildcarded column.
A special pattern is * (which is the same as  p/*/). For example:

  select *, !~p/*_DATA/ from 3C343.MS

selects all columns except the ones ending in _DATA.

  select ~m/DATA/, !~p/*_DATA/ from 3C343.MS

selects columns with a name containing DATA except the ones ending in _DATA.

  select CORRECTED_DATA, *, !~p/*_DATA/ from 3C343.MS  
or  
  select *, !~p/*_DATA/, CORRECTED_DATA from 3C343.MS

does select the CORRECTED_DATA column.
Note it is not possible to change the name or data type of wildcarded columns.

It is also possible to use expressions in the column list to create new columns based on the contents of other columns. When doing this, the resulting table is a plain table (because a reference table cannot contain expressions). The new column can be given a name by giving AS name after the expression (where AS is optional). If no name is given, a unique name like Col_1 is constructed. After the name a data type string can be given for the new column. If no data type is given, the expression data type is used.

  select max(ANTENNA1,ANTENNA2) AS ANTENNA from 3C343  
  select means(DATA,1) from 3C343

Note that unit conversion can be (part of) an expression. For example:

  select TIME d AS TIMEH from my.ms

to store the time in unit d (days). Units are discussed in section 4.9.

It is possible to change the data type of a column by specifying a data type (see below) after the new column name. Giving a data type (even if the same as the existing one) counts as an expression, thus results in the generation of a plain table. For example:

  select MODEL_DATA AS DATA FCOMPLEX from 3C343.MS

Note that for subqueries the GIVING clause offers a better (faster) way of specifying a result expression. It also makes it possible to use intervals.

Special aggregate functions (e.g., gmin) exist to calculate an aggregated value (minimum in this example) per group of rows where the grouping is deï¬ned by the GROUPBY clause. The entire column is a single group if no GROUPBY is given. Aggregation is discussed in more detail in section 5.

If a column_list is given and if all columns (and/or expressions) are scalars, the column_list can be preceded by the word DISTINCT. It means that the result is made unique by removing the rows with duplicate values in the columns of the column_list. Instead of DISTINCT the synonym NODUPLICATES or UNIQUE can also be used. To ï¬nd duplicate values, some temporary sorting is done, but the original order of the remaining rows is not changed.
Note that support of this keyword is mainly done for SQL compliance. The same (and more) can be achieved with the DISTINCT keyword in the ORDERBY clause with the difference that ORDERBY DISTINCT will change the order.
For full SQL compliance it is also possible to give the keyword ALL which is the opposite of DISTINCT, thus all values are returned. This is the default. Because there is an ambiguity between the keyword ALL and function ALL, the ï¬rst element of the column list cannot be an expression starting with a parenthesis if the keyword ALL is used.

3.2.1 Masked array in column_list

If an expression in the column_list is a masked array, it is possible to create two columns from it: one for the data, one for the mask. This can be done by combining them in parentheses like (DATA,MASK). A possible data type given after the column names only applies to the data column, since the mask column always has data type Bool. For example:

  select means(DATA[FLAG],0) as (MD,MM) C4 from in.ms giving out.tab

The select results in a masked array containing the means along axis 0. Both column MD and MM are ï¬lled with the contents of the masked array. MD (with data type C4) contains the means over the ï¬rst axis of the unmasked elements; MM contains the resulting mask.

[ AS options]]

3.3 INTO [table] [AS options]

This indicates that the ultimate result of the SELECT command should be written to a table (with the given name). This table can be a reference table, a plain table, or a memory table.

The table argument gives the name of the resulting table. It can be omitted if a memory table is created.

The options argument is optional and can be a single value or a list, enclosed in square brackets, consisting of values and key=value. They can be used to specify the table and storage type. All keys and values are case-insensitive.

TYPE=’value’
speciï¬es the table type.
PLAIN = make a persistent table, thus a true copy of all selected rows/columns.
SCRATCH = as plain, but only as a temporary table.
MEMORY = as plain, but keep everything in memory.
If TYPE is not given, a reference table is made if no expressions are given in the SELECT clause, otherwise a plain table is made.
ENDIAN=’value’
speciï¬es the endianness
BIG = big endian
LITTLE = little endian
LOCAL = native endianness of the machine being used
AIPSRC = as deï¬ned in the .casarc ï¬le (which usually defaults to LOCAL)
If ENDIAN is not given, it defaults to AIPSRC.
STORAGE=’value’
speciï¬es the storage type
SEPFILE = store as separate ï¬les (the old Casacore table format)
MULTIFILE = combine all storage manager ï¬les into a single ï¬le.
MULTIHDF5 = as MULTIFILE, but use an HDF5 ï¬le instead of a regular ï¬le.
DEFAULT = use SEPFILE (but might change in a future Casacore version),
AIPSRC = as deï¬ned in the .casarc ï¬le (which usually defaults to DEFAULT)
If STORAGE is not given, it defaults to AIPSRC.
BLOCKSIZE=n
speciï¬es the blocksize to use for MULTIFILE or MULTIHDF5.
OVERWRITE=F
tells that an existing table with the given name should not be overwritten. By default TaQL will overwrite existing tables.

For backward compatibility, it is possible to specify an option directly without having to use ’key=value’.

MEMORY
to store the result in a memory table.
SCRATCH
to store the result in a scratch table, possibly on disk.
PLAIN
to store the result in a plain table.
PLAIN_BIG
to store the result in a plain table in big-endian format.
PLAIN_LITTLE
to store the result in a plain table in little-endian format.
PLAIN_LOCAL
to store the result in a plain table in native endian format.

The standard TaQL way to deï¬ne the output table is the GIVING clause. INTO is available for SQL compliance.

If the INTO (or GIVING) clause is not given, the query result will be written into a memory table. In this way queries done in a readonly directory will not fail if a result table cannot created. However, if the result is expected to not ï¬t in memory (which will seldomly be the case), type SCRATCH should be used to make it ï¬t.

If the result is stored in a plain table, it is possible to give detailed data manager info for the result table using the DMINFO clause. See section 8.2 how the data manager info can be speciï¬ed.

3.4 FROM table_list

The FROM part deï¬nes the tables used in the query. It is a comma-separated list of tables, each followed by an optional shorthand (alias).

The full syntax is:

  FROM table1 [shorthand1], table2 [shorthand2], ...

Similar to SQL and OQL the shorthand can also be given using AS or IN. E.g.

  SELECT FROM mytable AS my, other IN ~user/othertable

Note that if using IN, the shorthand has to precede the table name. It can be seen as an iterator variable.

The shorthand can be used in the query to qualify the table to be used for a column, for example t0.DATA. The ï¬rst table in the list is the primary table which will be used if a column is not qualiï¬ed by a shorthand. Often a query uses a single table in which case a shorthand is not needed. Multiple tables require a shorthand and are useful when:

  • A keyword in another table is needed.
  • Columns from multiple tables are used (an implicit join). In such a case the tables must have the same number of rows. For example, a regression test could be done like:
      SELECT FROM test.MS t1, result.MS t2  
        WHERE not all(near(t1.DATA, t2.DATA))

If the table is normal table with a fully alphanumeric name, the shorthand defaults to that name. In practice a shorthand is always needed if multiple tables are used.

The FROM clause can be omitted, in which case the input is a virtual table with no columns. The number of rows in it is deï¬ned by the LIMIT and OFFSET value; it defaults to 1 row. It makes it possible to select column-independent expressions in the SELECT command. Note that these expressions do not need to be constant. For example

  SELECT rowid() LIMIT 31

creates a temporary table with column Col_1 and 31 rows containing the values 0..30.

A table can be given in a variety of ways.

  1. A persistent table can be used by giving its name which can contain path speciï¬cation and environment variables or the UNIX ~ notation. If the tablename contains a special character, the character can be escaped with a backslash or the table name can be enclosed in single or double quotes.
  2. A table name can be taken from a keyword in a previously speciï¬ed table. This can be useful in a subquery. The syntax for this is the same as that for specifying keywords in an expression. E.g.
      SELECT FROM mytable tab  
        WHERE col1 IN [SELECT subcol FROM tab.col2::key]

    In this example key is a table keyword of column col2 in table mytable (note that tab is the shorthand for mytable and could be left out).
    It can also be used for another table in the main query. E.g.

      SELECT FROM mytable, ::key subtab  
        WHERE col1 > subtab.key1

    In this example the keyword key1 is taken from the subtable given by the table keyword key in the main table.
    If a keyword is used as the table name, the keyword is searched in one of the tables previously given. The search starts at the current query level and proceeds outwards (i.e., up to the main query level). If a shorthand is given, only tables with that shorthand are taken into account. If no shorthand is given, only primary tables are taken into account.

  3. Opening a subtable using a path name like my.ms/ANTENNA will fail if my.ms is a reference table instead of the original table. Therefore the path of a subtable should be given using colons instead of slashes like my.ms::ANTENNA which is a slight extension of specifying table names in the previous bullet.
    In this way a subtable can always be found.
  4. Similar to OQL it is possible to use a nested query command in the FROM clause. This is a normal query command enclosed in square brackets or parentheses. Besides the SELECT command the COUNT and CREATE TABLE command can also be used. The table created can thereafter be used in the rest of the query command by using the shorthand given to that table. It can also be used in the remainder of the table_list, thus using it as a backreference. Such backreferencing can be useful to avoid multiple equal subqueries. E.g.
      select from MS,  
       [select from MS where sumsqr(UVW[1:2]) < 625]  
        as TIMESEL  
       where TIME in [select distinct TIME from TIMESEL]  
        &&  any([ANTENNA1,ANTENNA2] in  
          [select from TIMESEL giving  
            [iif(UVW[3] < 0, ANTENNA1, ANTENNA2)]])

    is a command to ï¬nd shadowed antennas for the VLA. Without the query in the FROM command the subqueries in the remainder of the command would have been more complex. Furthermore, it would have been necessary to execute that select twice.
    The command above is quite complex and cannot be fully understood before reading the rest of this note. Note, however, that the command uses the shorthand TIMESEL to be able to use the temporary table in the subqueries.

  5. Normally only persistent tables (i.e., tables on disk) can be used. However, it is also possible to use transient tables in a TaQL command given in Python, Glish, or C++. This is done by passing one or more table objects to the function executing the TaQL command. In the TaQL command a $-sign followed by a sequence number has to be given to indicate the correct object containing the transient table. E.g., if two table objects are passed $1 indicates the ï¬rst table, while $2 indicates the second one.
  6. It is possible to use a concatenation of tables with the same description by giving a list of tables enclosed in square brackets. In this way it is, for example, possible to do a query on the combined parts of a MeasurementSet partitioned in time. Each table in the list can be speciï¬ed in one of the ways mentioned in this section, including another table concatenation.
    For example:
      SELECT FROM [ms.part1, ms.part2, ms.part3] WHERE ...

    does a query on the three parts of an MS which are seen as a single table.
    It is possible to use glob ï¬lename patterns in such a list. For example

      SELECT FROM [ms.part*] WHERE ...

    is the same as the example above if no other ï¬les with such a name exist. An error is given if no table is found matching the pattern.

    Subtables of the concatenated tables can be concatenated as well. Alternatively, they can be assumed to be the same for all tables meaning that the subtable of the concatenation is the subtable of the ï¬rst table. For example, when partitioning a MeasurementSet in time, the ANTENNA subtable is the same for all parts, while the POINTING and SYSCAL subtables depend on time, thus have to be concatenated as well. Concatenation of subtables can be achieved by giving them as a comma-separated list of names after the SUBTABLES keyword. For example:

      SELECT FROM [ms.part1, ms.part2 SUBTABLES SYSCAL,POINTING]

    Usually the result of a TaQL query references the table given in the FROM. In this example the FROM table is the concatenation, which is only known during the query. In such a case the concatenation must be made persistent, which can be done by using a GIVING (or INTO) inside the concatenation speciï¬cation. Only the table name can be given, because the persistent concatenation only keeps the original table names; it does not make a copy of all data.
    For example:

      SELECT FROM [ms.part1, ms.part2 GIVING ms.conc]  
         WHERE ANTENNA1 != ANTENAA2 GIVING ms.cross

    selects the cross-correlation baselines from the concatenation. Note the two GIVING commands. The ï¬rst one makes the concatenation persistent, the second one is the query result of the query ms.cross. It references the matching rows in the persistent concatenation ms.conc which in its turn references the original parts.

3.5 WHERE expression

It deï¬nes the selection expression which must have a boolean scalar result. A row in the primary table is selected if the expression is true for the values in that row. The syntax of the expression is explained in a section 4.

3.6 GROUPBY group_list

It deï¬nes how rows have to be grouped. Usually a result per group will be calculated using aggregate functions. A group consists of all rows for which the columns (or expressions) given in the group_list have the same value. The (aggregate) expressions in the SELECT clause are calculated for the entire group. In this way one can get, for example, the mean XX amplitude and the number of time slots per baseline like:

  SELECT ANTENNA1,ANTENNA2,GMEAN(AMPLITUDE(DATA[,0])),GCOUNT()  
         FROM my.ms GROUPBY ANTENNA1,ANTENNA2

It results in a table containing nbaseline rows with in each row the antenna ids, mean amplitude, and number of rows.
If no aggregate function is used for a column, the value of the last row in the group is used. Note that in this example ANTENNA1 and ANTENNA2 are the same for the entire group. However, if TIME was also selected, only the last time would be part of the result.
Note that each expression in the group_list has to result in a scalar value of type bool, integer, double, date, or string.
Aggregate functions are discussed in more detail in section 5.

3.7 HAVING expression

This clause can be used to select speciï¬c groups. Only the groups (deï¬ned by GROUPBY) are selected for which the HAVING expression is true.
Note that HAVING can be given without GROUPBY, although that will hardly ever be useful. If no GROUPBY is given, but the SELECT statement contains an aggregate function, the result is a single group. HAVING cannot be used if neither GROUPBY nor SELECT aggregate functions are used.
It is discussed in more detail in section 5.

3.8 ORDERBY sort_list

It deï¬nes the order in which the result of the selection has to be sorted. The sort_list is a comma separated list of expressions. It operates on the output of the SELECT, thus after a possible GROUPBY and HAVING clause are executed.
The sort_list can be preceded by the word ASC or DESC indicating if the given expressions are by default sorted in ascending or descending order (default is ASC). Each expression in the sort_list can optionally be followed by ASC or DESC to override the default order for that particular sort key.
To be compliant with SQL whitespace can be used between the words ORDER and BY.

The word ORDERBY can optionally be followed by DISTINCT which means that only the ï¬rst row of multiple rows with equal sort keys is kept in the result. To be compliant with SQL dialects the word UNIQUE or NODUPLICATES can be used instead of DISTINCT.

An expression can be a scalar column or a single element from an array column. In these cases some optimization is performed by reading the entire column directly.
It can also be an arbitrarily complex expression with exactly the same syntax rules as the expressions in the WHERE clause. The resulting data type of the expression must be a standard scalar one, thus it cannot be a Regex or DateTime (see below for a discussion of the available data types). E.g.

  ORDERBY col1, col2, col3  
  ORDERBY DESC col1, col2 ASC, col3  
  ORDERBY NODUPLICATES uvw[1] DESC  
  ORDERBY square(uvw[1]) + square(uvw[2])  
  ORDERBY datetime(col)       # incorrect data type  
  ORDERBY mjd(datetime(col))  # is correct

3.9 LIMIT/OFFSET expression

It indicates which of the matching and sorted rows should be selected. If not given, all of them are selected. The word TOP can also be used instead of LIMIT.
LIMIT and OFFSET are applied after ORDERBY and SELECT DISTINCT, so they are particularly useful in combination with those clauses to select, for example, the highest 10 values.

It can be given in two ways:

  • In the semi-standard SQL way using LIMIT N to select N rows and/or OFFSET M to skip the ï¬rst M rows. Similar to Python, N and M can be negative meaning they are counted from the end. E.g., LIMIT -1 means all rows but the last.
  • As a Python-style range using LIMIT start:end:incr, where the end is exclusive. Start defaults to 0, end to the number of rows, and incr to 1. As above, start and end can be negative to count from the end. The increment must be positive.

For example:

  SELECT FROM my.tab ORDERBY DISTINCT TIME LIMIT 2 OFFSET 10  
  SELECT FROM my.tab ORDERBY DISTINCT TIME LIMIT 10:12

sorts uniquely by time, skips the ï¬rst 10 rows, and selects the next two rows.

  SELECT FROM my.tab LIMIT ::100

selects every 100-th row.

[ AS options] — set]

3.10 GIVING [table] [AS options] — set

It indicates that the ultimate result of the SELECT command should be written to a table (with the given name).
Another (more SQL compliant) way to deï¬ne the output table is the INTO clause. See INTO for a more detailed description including the possible types.

It is also possible to specify a set in the GIVING clause instead of a table name. This is very useful if the result of a subquery is used in the main query. Such a set can contain multiple elements Each element can be a single value, range and/or interval as long as all elements have the same data type. The parts of each element have to be expressions resulting in a scalar.

In the main query and in a query in the FROM command the GIVING clause can only result in a table and not in a set.
To be compliant with SQL dialects, the word SAVETO can be used instead of GIVING. Whitespace can be given between SAVE and TO.

4 Expressions

An expression is the basic building block of TaQL. They are similar to expressions in other languages. An expression is formed by applying an operator or a function to operands which can be a table column or keyword, a constant, or a subexpression. An operand can be a scalar value or an array or set. The next subsections discuss them in detail.

An expression can be used in several places:

  • In the WHERE and HAVING clause where the result must be a boolean scalar value. It tells if a table row or group will be selected.
  • As a key in the GROUPBY clause where the result must be a scalar value (numeric, bool, or string).
  • As a sort key in the ORDERBY clause where the result must be a scalar value (numeric, bool, or string)
  • As an element in the set in the GIVING clause. It must be a scalar value of any type except regex.
  • As a scalar or array value in the INSERT and UPDATE command.
  • As a column expression in the column-list part of the SELECT command. The result can be a scalar or array value.
  • As a scalar or array value in the CALC command.
  • As a scalar or array value in various ALTER TABLE subcommands

The expression in the clause can be as complex as one likes using arithmetic, comparison, and logical operators. Parentheses can be used to group subexpressions.
The operands in an expression can be table columns, table keywords, constants, units, functions, sets and intervals, and subqueries.
The index operator can be used to take a single element or a subsection from an array expression.
For example,

  column1 > 10  
  column1 + arraycolumn[index] >= min (column2, column3)  
  column1 IN [expr1 =:< expr2]

The last example shows a set with a continuous interval.

4.1 Data Types

Internally TaQL uses the following data types:

Bool
logical values (true/false (case-insensitive) or T/F)
Integer
integer numbers up to 64 bits
Double
64 bit floating point numbers including times/positions
Complex
128 bit complex numbers
String
string values on which operator + can be used (concatenation).
Regex
regular expressions can be used for string matching (see section 4.2). Maximum string distances can also be used in a way similar to regular expressions.
DateTime
representing a date/time. There are several functions acting on a date/time. Operator + and - can be used on them.

Scalars and arbitrarily shaped arrays of these data types can be used. However, arrays of Regex are not possible.
If an operand or function argument with a non-matching data type is used, TaQL will do the following automatic conversions:
- from Integer to Double or Complex.
- from Double to Complex.
- from String or Double to DateTime.

In this document some special data types are used when describing the functions.
- Real means Integer or Double.
- Numeric means Integer, Double, or Complex.
- DNumeric means Double or Complex.

TaQL supports any possible data type of a table column or keyword. In some commands (column list and CREATE TABLE) columns are created where it is possible to specify the data type of a column. The following case-insensitive values can be used to specify a type:

  B          BOOL       BOOLEAN  
  U1         UCHAR      BYTE  
  I2         SHORT      SMALLINT  
  U2   UI2   USHORT     USMALLINT  
  I4         INT        INTEGER  
  U4   UI4   UINT       UINTEGER  
  R4   FLT   FLOAT  
  R8   DBL   DOUBLE  
  C4   FC    FCOMPLEX   COMPLEX  
  C8   DC    DCOMPLEX  
  S          STRING  
  TIME       DATE       EPOCH

The TIME type is a special data type. It means that the column gets data type DOUBLE and that a MEASINFO record will be deï¬ned in the column keywords to designate the column as an epoch.

4.2 Regular Expressions and String Distances

TaQL supports the use of extended regular expressions and string distances. They can be speciï¬ed in various ways as discussed in section 4.3.6. There are three basic types of regular expressions.

  • An SQL-style pattern is quite simple. It has 2 special characters. The underscore (_) means a single arbitrary character and the percent (%) means zero or more arbitrary characters. Special characters can be escaped with a backslash to retain their normal meaning. For example:
      3c\_%

    matches 3c_ and 3c_xx, but not 3caxx.

  • A UNIX-style pattern, as often used for wildcarded ï¬le names, is more powerful than the SQL-style pattern. It has a few special characters that can be escaped with a backslash.
    • The question mark (?) means a single arbitrary character.
    • The asterisk (*) means zero or more arbitrary characters. For example: 3c_* does the same as the SQL-style pattern above.
    • Square brackets indicate a bracket expression (character choice). For example: [ab] matches a and b, but not c. A few special characters can be used in a bracket expression:
      • A leading ^ or ! means negation. Thus [!ab] matches every character except a and b.
      • A minus sign indicates a range. For example [0-9] matches a digit or [a-z] matches a lowercase letter. If a minus sign cannot be interpreted as a range, it is a literal minus sign like in [-ab] or the second minus sign in [a-z-A].
      • Posix character classes [:xx:] where xx can be:
        - alpha matching any letter
        - lower matching any lowercase letter
        - upper matching any uppercase letter
        - alnum matching any digit or letter
        - digit matching any digit
        - xdigit matching any hexadecimal digit (0-9a-fA-F)
        - space matching any whitespace character
        - print matching any printable character (alnum, punct, space)
        - punct matching any non-alnum visible character (.,!? etc.)
        - graph matching any visible printable character (alnum, punct)
        - cntrl matching any control character.
        For example [_[:isalpha:]][_[:isalnum:]]* to match variable names.
      • A bracket expression cannot be empty, thus if ] is the ï¬rst character in the bracket expression, it is interpreted literally. Note that is also true if it is the ï¬rst character after the negation character.
      • A backslash in a character class is always interpreted literally, thus special characters cannot be escaped. However, as shown above they can always be placed such that they are interpreted literally.
    • Braces can be used for a choice between (possible empty) multi-character strings separated by commas. Escape a comma or brace with a backslash to treat it literally. For example:
      *.{h,hpp,c,cc,cpp}
      It is fully nestable, thus choice strings can be patterns. For example:
      *.{[hc]{,pp},c}
      does the same as the example above. Note that the inner choice is between an empty string and pp.
  • An awk/egrep-like extended regular expression is most powerful. A full explanation can be found on Wikipedia. Here only a summary of its special characters is given. They can be escaped using backslashes.
    • . matches any character.
    • ^ matches beginning of string.
    • $ matches end of string.
    • Square brackets for a bracket expression. It is the same as described above with the exception that ! cannot be used as negation character.
    • * matches zero or more occurrences of previous character or subexpression.
    • + matches one or more occurrences.
    • ? matches zero or one occurrence.
    • { and } for an interval giving minimum and maximum number of occurrences. For example:
      [a-z]{3,5} matches lowercase string with a minimum of 3 and maximum of 5 characters.
      [a-z]{3} matches exactly 3 characters.
      [a-z]{3,} matches at least 3 characters.
      [a-z]{,5} matches at most 5 characters.
    • | matches left or right substring
    • ( and ) to form subexpressions for operators like *.
    • \1 till \9 mean backreference to a subexpression (ï¬rst one is \1). A string part matches if it is equal to the string part matching that subexpression. e.g., (a*)x\1 matches x, axa, aaxaa, etc., but not axaa nor aaxa.

    For example:

      .*\.(h|hpp|c|cc|cpp)  
      .*\.[hc](pp)?|cc

    do the same as the pattern examples above.

Furthermore it is possible to specify maximum string distances (known as Levensthein or Edit distance). It is explained in section 4.3.6.

  column ~ d/string/ibnn

4.3 Constants

Scalar constants of the various data types can be formed in a way similar to Python and Glish. Array constants can be formed from scalar constants.

4.3.1 Bool

A Bool constant is the value T or F (both in uppercase) or the value true or false (any case).

4.3.2 Integer

An integer constant is a numeric value without decimal point or exponent. It can also be given as a hexadecimal value like 0xffff.

4.3.3 Double (and time/position)

A floating-point constant is given with a decimal point and/or exponent. ’E’ or ’e’ can be used to specify the exponent. An integer number followed by a unit is also regarded as a double constant.
Another way to deï¬ne a Double constant is by means of a Time or Position. Such a constant is always converted to radians. It can be given in several ways:

  • An integer or floating-point number immediately followed by a simple unit (thus without whitespace). e.g., 12.43deg
    Some valid units are deg, arcmin, arcsec (or as), rad. The units can be scaled by preceding them with a letter (e.g., mrad is millirad).
  • A time/position in HMS format. Seconds can be left out. e.g., 12h34m34.5 or 8h32m
  • A position in DMS format. Seconds can be left out. e.g., 12d34m34.5 or 8d0m
  • A position as DMS in dot format. Note that all parts must be present. e.g., 12.34.34.5 or 8.0.34.5

4.3.4 Complex

The imaginary part of a Complex constant is formed by an Integer or Double constant immediately followed by a lowercase i or j. A full Complex constant is formed by adding another Integer or Double constant as the real part. E.g.

  1.5 + 2j  
  2i+1.5            is identical  
  

Note that a full Complex constant has to be enclosed in parentheses if, say, a multiplication is performed on it. E.g.

  2 * (1.5+2i)  
  

4.3.5 String

A String constant has to be enclosed in †or ’ and can be concatenated (as in C++). E.g.

  "this is a string constant"  
  ’this is a string constant containing a "’  
  "ab’cd"’ef"gh’  
      which results in:   ab’cdef"gh  
  

4.3.6 Regular expression and String distance

A regular expression constant can be given directly or using a function.

  • An SQL-style pattern can be given directly as a string constant preceded by operator LIKE or NOT LIKE.
  • A pattern or regular expression can be given like x/expr/q preceded by operator ~ or !~. Instead of a slash, the characters % and # can also be used as delimiter, as long as the same delimiter is used on both sides. The delimiter can not be part of the expression (not even escaped with a backslash).
    The x denotes the type:
    - p means a pattern matching the full string.
    - f means a regular expression matching the full string.
    - m means a regular expression matching part of the string (a la Perl).
    The q denotes optional qualiï¬ers. Currently only i is supported meaning a case-insensitive match. For example:
      name~p/3[cC]*/  
      name ~ p%3c*%i  
      lower(name) ~ p%3c*%  
      name ~ m/^3c/i  
      name ~ f/3c.*/i  
      filename !~ p#/usr/*.{h,cc}#

    All examples but the last one do the same: matching a name starting with 3c or 3C.
    The last example shows a glob-style pattern to ï¬nd ï¬les on /usr not ending in .h or .cc.

  • Apart from these Perl-like speciï¬cations, a regular expression can also be formed by applying a function to a string constant. The operator = or != has to be applied to it.
    • Function sqlpattern treats its argument as an SQL-style pattern. For example:
        lower(name) LIKE ’3c%’  
        lower(name) = sqlpattern(’3c%’)

      do the same.

    • Function pattern treats its argument as a UNIX-style pattern.
    • Function regex treats its argument as a full regular expression.

    Case-insensitive matching can only be done as shown in the example above by downcasing the string to be matched.
    Please note that these functions are not limited to constants. They can also be used to form regular expressions from variables.

A maximum string distance constant can be speciï¬ed in a similar way. Such a distance is known as the Levensthein or Edit distance. It is a measure of the similarity of strings by counting the minimum number of edits (deletions, insertions, substitutions, and swaps of adjacent characters) that need to be done to make the strings equal.

  column ~ d/string/ibnn

This tests if the strings in the given column are within the maximum distance of the string given in the constant. The following qualiï¬ers can be given (in any order):

  • i means a case insensitive test.
  • b means that blanks in the strings are ignored.
  • nn is an integer value giving the maximum distance. If not given it defaults to 1 + len(string) / 3.

4.3.7 Date/time

DateTime constant can be formed in 2 ways:

  1. From a String constant using the datetime function. In this way all possible formats as explained in class MVTime are supported. E.g.
      datetime ("11-Dec-1972")

  2. A more convenient way is to specify it directly. Since this makes use of the delimiters space, - or /, it conflicts with the expression grammar as such. However, possible conflicts can be solved by using whitespace in an expression and it is believed that in practice the convenience surpasses the possible conflicts.
    A large subset of the MVTime formats is supported. A DateTime has to be speciï¬ed as date/time or date-time, where the time part (including the space, -, or / delimiter) is optional. The possible date formats are:
    - YYYY/MM/DD, YYYY-MM-DD, or DD-MM-YYYY where DD and MM must be 2 digits and YYYY 4 digits.
    - DD-MMMMMMMM-YY where the - is optional and MMMMMMM is the case-insensitive name of the month (at least 3 letters). DD can be 1 or 2 digits and YY 1 to 4 digits. 2000 is added if YY <50 and 1900 is added if 50 <=YY <100.
    If MM >12, YYYY will be incremented accordingly.
    The general time format in a DateTime constant is:
    - hh:mm:ss.s
    where the delimiter h or H can be used for the ï¬rst colon and m or M for the second. Trailing parts can be omitted. E.g.
      10-02-1997  
      10-February-97  
      10feb97  
      1997/02/10         are all identical  
     
      1May96/3:          : (or h) is mandatory  
      1May96-3:0  
      1May96 3:0:0  
      1May96-3h          h (or :) is mandatory  
      1May96 3H0  
      1May96/3h0M  
      1May96/3hm0.0

    A DateTime constant with the current date/time can be made by using the function datetime without arguments.

4.3.8 Arrays

N-dimensional arrays of all data types can be created with the exception of regular expressions.
It is possible to form a 1-dimensional array from a constant bounded discrete set. When needed such a set is automatically transformed to an array. E.g.

  [0:10]  
  [’str1’, ’str2’, ’str3’]  
  ’str’ + [’1’, ’2’, ’3’]

The ï¬rst example results in an integer array of 10 elements with values 0..9. The others result in a string array of 3 elements. The second version already shows that strings can be concatenated (as explained further on).

A multi-dimensional array can be formed by giving a set of arrays. A nested list resembles the numpy way. For example:

  [[1,2,3],[4,5,6]]

results in a 2-dim array. However, it is also possible to use arrays created in other ways such as arrays in a column or arrays created with the array function described below. For example:

  [[[1,2,3],[4,5,6]], array([10:13],2,3)]

results in a 3-dim array.

Furthermore it is possible to use the array function to create an array of any shape. The values are given in the ï¬rst argument as a scalar, set, or another array. The shape is given in the latter arguments as scalars or as a set. The array is initialized to the values given which are wrapped if the array has more elements.

  array([1:11],10,4)  
  array([1:11], [10,4])  
  array(F,shape(DATA))

The ï¬rst examples create an array with shape [10,4] containing the values 1..10 in each line. The latter results in a boolean array having the same shape as the DATA array and ï¬lled with False.

4.3.9 Masked Arrays

An array can have an optional mask. Similar to numpy’s masked array, a mask value True means that the value is masked off, thus not taken into account in reduce functions like calculating the mean.
Note that this deï¬nition is the same as the FLAG column in a MeasurementSet, but is different from a mask in a Casacore Image where True means good and False means bad.

All operations on arrays will take the possible mask into account. Reduce functions like median only use the unmasked array elements. Furthermore, partial reduce functions like medians will set an output mask element to True if the corresponding input array part has no unmasked elements.
Operators like + and functions like cos operate on all array elements. The mask in the resulting array is the logical OR of the input masks. Of course, the result has no mask if no input array has a mask.

A masked array is created by applying a boolean array to an array using the square brackets operator. Both arrays must have the same shape. For example:

  DATA[FLAG]  
  DATA[DATA > 3*median(abs(DATA))]

The ï¬rst example applies the FLAG column in a MeasurementSet to the DATA column. The second example masks off high DATA values.

The functions arraydata, arraymask, and flatten can be used to get the array data or mask. The last one flattens the array to a vector while removing all masked elements.

The TaQL commands putting values into a table accept two columns (in parentheses) for a masked array. This is described in more detail in the appropriate sections. For example:

  select means(DATA[FLAG],0) as (MD,MM) from in.ms giving out.tab

to write the data averaged over the ï¬rst axis (frequency channel)into column MD. Only the unflagged data points are taken into account. The output contains the resulting flags in column MM; a flag is set to True if all channels were flagged.

4.3.10 Null Arrays

A cell in a table column containing variable shaped arrays, can be empty. Such a cell does not contain an array and is represented in TaQL as a null array. Note it is different from a cell containing an empty array, which is an array without values.

Null arrays can be used with any operator and in any function. If one of the operands or function arguments is a null array, the result will be a null array; only array functions reducing to a scalar (such as sum and mean) give a valid value (usually 0).

The UPDATE and INSERT commands will ignore a null array result; no value is written in that row.

4.4 Table Columns

A table column can be used in a query by giving its name in the expression, possibly qualiï¬ed with a table shorthand name. A column can contain a scalar or an array value of any data type supported by the table system. It will be mapped to the available TaQL data types. If the column keywords deï¬ne a unit for the column, the unit will be used by TaQL.

The name of a column can contain alphanumeric characters and underscores. It should start with an alphabetic character or underscore. A column name is case-sensitive.
It is possible to use other characters in the name by escaping them with a backslash. e.g., DATE\-OBS.
In the same way a numeric character can be used as the ï¬rst character of the column name. e.g., \1stDay.
A reserved word cannot be used directly as a column name. It can, however, be used by escaping it with a backslash. e.g., \IN.
Note that in programming languages like C++ and Python a backslash itself has to be escaped by another backslash. e.g., in Python: tab.query(’DATE\\-OBS >10MAR1996’).

If a column contains a record, one has to specify a ï¬eld in it using the dot operator; e.g., col.fld means use ï¬eld fld in the column. It is fully recursive, so col.fld.subfld can be used if ï¬eld fld is a record in itself.
Alas records in columns are not really supported yet. One can specify ï¬elds, but thereafter an error message will be given.

4.4.1 Referring to SELECT columns

Usually a column used in an expression will be a column in one of the tables speciï¬ed in the FROM clause. However, it is possible to use a column created in the SELECT clause, in expressions given in the HAVING or ORDERBY clause. In fact, a column name not preceded by a table shorthand, is ï¬rst looked up in the SELECT columns and thereafter in the ï¬rst FROM table.

It can be advantageous to use a SELECT column if that column is an expression; it saves both typing and execution time. because that expression is executed only once.

4.5 Table Keywords

It is possible to use table or column keywords, which can have a scalar or an array value or a record, possibly nested. A table keyword has to be speciï¬ed as ::key. In an expression the :: part can be omitted if there is no column with the same name. A column keyword has to be speciï¬ed as column::key.
Note that the :: syntax is chosen, because it is similar to the scope operator in C++.
As explained in the FROM clause, keywords in the primary table and in other tables can be used. If used from another table, it has to be qualiï¬ed with the (shorthand) name of the table. E.g.,
sh.key or sh.::key
takes table keyword key from the table with the shorthand name sh.

If a keyword value is a record, it is possible to use a ï¬eld in it using the dot operator. e.g., ::key.fld to use ï¬eld fld. It is fully recursive, so if the ï¬eld is a record in itself, a subï¬eld can be used like col::key.fld.subfld

A keyword can be used in any expression. It is evaluated immediately and transformed to a constant value.

4.6 Operators

TaQL has a fair amount of operators which have the same meaning as their C and Python counterparts. The operator precedence order is:

  **  
  !  ~  +  -       (unary operators)  
  *  /  // %  
  +  -  
  &  
  ^  
  |  
  == != >  >= <  <=  ~= !~= IN INCONE BETWEEN EXISTS LIKE  ~  !~  
  &&  
  ||

Operator names are case-insensitive. For SQL compliancy some operators have a synonym.

  ==     =  
  !=     <>  
  &&     AND  
  ||     OR  
  !      NOT  
  ^      XOR

All operators can be used for scalars and arrays and a mix of them. Note that arrays of regular expressions cannot be used.

The following table shows all available operators and the data types that can be used with them.

Operator

Data Type

Description




**

numeric

power. It is right associative, thus 2**1**2 results in 2.

*

numeric

multiplication

/

numeric

non-truncated division, thus 1/2 results in 0.5

//

real

truncated division (a la Python) resulting in an integer, thus 1./2. results in 0

%

real

modulo; 3.5%1.2 results in 1.1; -5%3 results in -2

+

no bool

addition. If a date is used, only a real (converted to unit day) can be added to it. String addition means concatenation.

-

numeric,date

subtraction. Substracting a date from a date results in a real (with unit day). Subtracting a real (converted to unit day) from a date results in a date.

&

integer

bitwise and

|

integer

bitwise or

^, XOR

integer

bitwise xor

==, =

all

comparison for equal. The norm is used when comparing complex numbers.

>

no bool

comparison for greater

>=

no bool

comparison for greater or equal

<

no bool

comparison for less

<=

no bool

comparison for less or equal

! =, <>

all

comparison for not equal

~=

numeric

shorthand for the NEAR function with a tolerance of 1e-5

!~=

numeric

shorthand for NOT NEAR with a tolerance of 1e-5

&&, AND

bool

logical and

||, OR

bool

logical or

!, NOT

bool

logical not

~

integer

bitwise negation

+

numeric

unary plus

-

numeric

unary minus

~

string

test if string matches a regular expression constant.

!~

string

test if string does not match a regular expression constant.

LIKE

string

test if a string matches an SQL pattern.

NOT LIKE

string

test if string does not match an SQL pattern.

IN

all

test if a value is present in a set of values, ranges, and/or intervals. (See the discussion of sets).

NOT IN

all

negation of IN

BETWEEN

no bool

x BETWEEN b AND c is similar to x>=b AND x<=c and x IN [b=:=c]

NOT BETWEEN

no bool

a NOT BETWEEN b AND c is negation of above.

INCONE

cone search. (See the discussion of cone search functions).

NOT INCONE

negation of INCONE

EXISTS

test if a subquery ï¬nds at least N matching rows. The value for N is taken from its LIMIT clause; if LIMIT is not given it defaults to 1. The subquery loop stops as soon as N matching rows are found. E.g. EXISTS(select from ::ANTENNA where NAME=’’somename’’ LIMIT 2) results in true if at least 2 matching rows in the ANTENNA table were found.

NOT EXISTS

negation of EXISTS

4.7 Sets and intervals

As in SQL the operator IN can be used to do a selection based on a set. E.g.

  SELECT FROM table WHERE column IN [1,2,3]

The result of operator IN is true if the column value matches one of the values in the set. A set can contain any data type except a regex.

This example shows that (in its simplest form) a set consists of one or more values (which can be arbitrary expressions) separated by commas and enclosed in square brackets. The elements in a set have to be scalars and their data types have to be the same or convertible to a common data type. The square brackets can be left out if the set consists of only one element. For SQL compliance parentheses can be used instead of square brackets.

An array is also a set, so IN can also be used on an array like:

  SELECT FROM table WHERE column IN expr1

where expr1 is the array result of some expression. It is also possible to use a scalar as the righthand of operator IN. So if expr1 is a scalar, operator IN gives the same result as operator ==.

The lefthand operand of the IN operator can also be an array or set. In that case the result is a boolean array telling for each element in the lefthand operand if it is found in the righthand operand.

An element in a set can be more complicated than a single value. It can deï¬ne multiple values and intervals. The possible forms of a set element are:

  1. A single value as shown in the example above.
  2. start:end:incr. This is similar to the way an array index is speciï¬ed. Incr defaults to 1. End defaults to an open end (i.e., no upper bound) and results in an unbounded set. Start and end can be a real or a datetime. Incr has to be a real. Some examples:
      1:10         means 1,2,...,9  (also 10 when using glish style)  
      1:10:2       means 1,3,5,7,9  
      1::2         means all odd numbers  
      1:           means all positive integer numbers  
      18Aug97::2   means every other day from 18Aug97 on

    These examples show constants only, but start, end, and incr can be any expression.
    Note that :: used here can conflict with the :: in the keywords. e.g., a::b is scanned as a keyword speciï¬cation. If the intention is start::incr, whitespace should be used as in a: :b. In practice this conflict will hardly ever occur.

  3. Continuous intervals can be speciï¬ed for data type real, string, and datetime. The speciï¬cation of an interval resembles the mathematical notation 1<x<5, where x is replaced by :. An open interval side is indicated by <, while a closed interval side is indicated by =.
    Another way to specify intervals is using curly and/or angle brackets. A curly bracket is a closed side, the angle bracket is an open side. The following examples show how bounded and half-bounded, (half-)open and closed intervals can be speciï¬ed.
      1=:=5   {1,5}     means 1<=x<=5   bounded closed  
      1<:<5   <1,5>     means 1<x<5     bounded open  
      1=:<5   {1,5>     means 1<=x<5    bounded right-open  
      1<:=5   <1,5}     means 1<x<=5    bounded left-open  
      1=:  {1,}  {1,>   means 1<=x      left-bounded closed  
      1<:  <1,}  <1,>   means 1<x       left-bounded open  
      :=5  {,5}  <,5}   means x<=5      right-bounded closed  
      :<5  {,5>  <,5>   means x<5       right-bounded open

It is very important to note that the 2nd form of set speciï¬cation results in discrete values, while the 3rd form results in a continuous interval.

Each element in a set can have its own form, i.e., one element can be a single value while another can be an interval. If a set consists of single or bounded discrete start:end:incr values only, the set will be expanded to an array. This makes it possible for array operators and functions (like mean) to be applied to such sets. E.g.

  WHERE column > mean([10,30:100:5])

Another form of constructing a set is using a subquery as described in section 4.11.

4.8 Array Index Operator

It is possible to take a subsection or a single element from an array column, keyword or expression using the index operator [index1,index2,...]. This syntax is similar to that used in Python or Glish. Similar to Python a negative value can be given meaning counting from the end. However, a negative stride cannot be given. Taking a single element can be done as:

  array[1, 2]  
  array[-1, -1]                  last element  
  array[1, some_expression]

Taking a subsection can be done as:

  array[start1:end1:incr1, start2:end2:incr2, ...]

If a start value is left out it defaults to the beginning of that axis. An end value defaults to the end of the axis and an increment defaults to one. If an entire axis is left out, it defaults to the entire axis.
E.g., an array with shape [10,15,20] can be subsectioned as:

  [,,3]               resulting in an array of shape [10,15,1]  
  [2:4, ::3, 2:15:2]  resulting in an array of shape [3,5,7]  
                      (NB. shape is [2,5,7] for python style)  
  [-1:-1,,]           last element of first axis, all elements other axes

The examples show that an index can be a simple constant (as it will usually be). It can also be an expression which can be as complex as one likes. The expression has to result in a real value which will be truncated to an integer.
For ï¬xed shaped arrays checking if array bounds are exceeded is done at parse time. For variable shaped arrays it can only be done per row. If array bounds are exceeded, an exception is thrown. In the future a special undeï¬ned value will be assigned if bounds of variable shaped arrays are exceeded to prevent the selection process from aborting due to the exception.

Note that the index operator will be applied directly to a column. This results in reading only the required part of the array from the table column on disk. It is, however, also possible to apply it to a subexpression (enclosed in parentheses) resulting in an array. E.g.

  arraycolumn[2,3,4] + 1  
  (arraycolumn + 1)[2,3,4]

can both be used and have the same result. However, the ï¬rst form is faster, because only a single element is read (resulting in a scalar) and 1 is added to it. The second form results in reading the entire array. 1 is added to all elements and only then the requested element is taken.
From this example it should be clear that indexing an array expression has to be done with care.

4.9 Units

Units can be given at many places in an expression; in fact, each subexpression can be ended with a unit meaning that the subexpression result gets that unit or will be converted to that unit. A simple unit (only letters) can always be given literally. A non-simple unit can be given literally if only containing digits, underscores and/or dots (e.g., m2, fl_oz. or m.m). Otherwise the unit has to be enclosed in single or double quotes (e.g., ’m/s’) or the backslash has to be used as escape character (e.g., \in or m\/s).
Arguments to functions like sin will be converted to the appropriate unit (radians) as needed. In a similar way, the units of operands to operators like addition, will be converted as needed. An exception is thrown if a unit conversion is not possible.

All units supported by module Quanta can be used. Note that the units are case sensitive. Most common units use lowercase characters. A unit can be preceded by a scaling preï¬x (like k for kilo). Compound units are created when multiplying or dividing values with units. The available units can be shown using the show units command of the program taql.

Units can be given as follows:

  • If a column has a unit deï¬ned in column keyword QuantumUnits or UNIT, it automatically gets that unit.
  • A constant can immediately be followed by a simple unit. e.g., 2deg.
  • The result of several expressions have an implicit unit.
    Constants given as positions are in radians (rad).
    Difference of 2 dates is in days (d).
    Inverse trigonometric functions like asin give radians.
  • When combining values with different units in e.g., an interval, a set, an addition, or a function like min, the values are converted to the unit of the ï¬rst operand or argument with a unit. Values without a unit have by default the unit of the ï¬rst operand or argument with a unit.
      3mm-7cm          result is -67 mm  
      3+3mm            result is 6 mm  
      3mm<:<3cm        result is interval <3mm,30mm>  
      [3,4cm,5]        result is [3cm, 4cm, 5cm]  
      [5, 7cm, 8mm]    result is [5cm, 7cm, 0.8cm]  
      [5, 7mm, 8cm]    result is [5mm, 7mm, 80mm]  
      max(3mm,2cm)     result is 20 mm  
      5 ’km/h’ + 1 ’m/s’      is 8.6 km/h  
      iif(F,3min,30sec)       is 0.5 min

  • Similarly, operands of comparison operators and arguments of comparison functions (like near) are converted to the unit of the ï¬rst operand or argument with a unit.
  • The result of a multiplication and division is a compound unit if both operands have a unit. Otherwise it is the unit of the argument with a unit.
    Before TaQL supported units, it was needed to divide the TIME column in a MeasurementSet by 86400 to convert it to days, so it could be compared with a given date/time. So, for backward compatibility, a division of a value with unit s by a constant 86400 results in unit d.
  • Division of units of an equal kind (e.g., km by m) results in a unitless value.
  • Division of a unitless value by a value with unit, results in the reciproke unit.
      1km/10m          result is 100  
      1/2s             result is 0.5 ’(s)-1’  
      1Hz + 1/2s       result is 1.5Hz

  • The result of functions like SUMSQR and SQRT is a compound unit if the argument has a unit. Note that sqrt(2m) will fail, because the square root of a meter does not exist.
  • A (sub)expression can be followed by a simple or compound unit. If the subexpression has no unit, it gets the given unit. Otherwise the resulting value is converted to the unit.
    Note that some units can be the same as a reserved word (e.g., as or in). In that case it has to be escaped or enclosed in quotes.
      COL \in          set/convert column COL to inch  
      3 cm             result is 3 cm  
      3 ’km/s’         result is 3 km/second  
      3mm cm           result is 0.3 cm  
      (3mm cm)m        result is 0.003 m  
      (3+3) cm         result is 6 cm  
      (3+3mm) cm       result is 0.6 cm  
      [3,4,5]mm        result is [3mm, 4mm, 5mm]  
      [3,4cm,5]mm      result is [30mm, 40mm, 50mm]  
          Note: all values in the set first get the same unit cm  
      asin(1)          result is pi/2 radians  
      asin(1) deg      result is 90 degrees  
      (3mm+7cm) m      result is 0.073 m

  • If a function argument is expected in a certain unit, values are converted as needed. For example, arguments to functions sin and anycone are automatically converted to radians.
  • When adding or subtracting a value from a date, that value is converted to unit d (days).

Units will probably mostly be used in an expression in the WHERE clause or in a CALC command. However, it is also possible to use a unit in the selection of a column in the SELECT clause. For example:

  select TIME d as TIMED from my.ms

In such a case the selection is an expression and the unit is stored in the column keywords. Thus in this example, TIME is stored in a column TIMED with keyword QuantumUnits=d and the values are converted to days.

4.10 Functions

More than 100 functions exist to operate on scalar and/or array values. Some functions have two names. One name is the CASA/Glish name, while the other is the name as used in SQL. In the following tables the function names are shown in uppercase, while the result and argument types are shown in lowercase. Note, however, that function names are case-insensitive.
Furthermore it is possible to have user deï¬ned functions that are dynamically loaded from a shared library. In section Writing user deï¬ned functions it is explained how to write user deï¬ned functions.
A set of standard UDFs exists dealing with Measure conversions, for example to convert J2000 to apparent. Another set of UDFs deals with values and relations in MeasurementSets and Calibration Tables.

Sets, and in particular subqueries, can result in a 1-dim array. This means that the functions accepting an array argument can also be used on a set or the result of a subquery.

4.10.1 String functions

These functions can be used on a scalar or an array argument.

integer STRLENGTH(string), integer LEN(string)
Returns the number of characters in a string (trailing whitespace is signiï¬cant).
string UPCASE(string), string UPPER(string)
Convert to uppercase.
string DOWNCASE(string), string LOWER(string)
Convert to lowercase.
string CAPITALIZE(string)
Capitalize a string (make ï¬rst letter uppercase).
string LTRIM(string)
Removes leading whitespace.
string RTRIM(string)
Removes trailing whitespace.
string TRIM(string)
Removes leading and trailing whitespace.
string SUBSTR(string, integer ST, integer N)
Returns a substring starting at the 0-based position ST with a length of at most N characters. If the string argument is an array of strings, an array with the substring of each string is returned. The arguments ST and N have to be scalar values. If ST is negative, it counts from the end (a la Python). N and the resulting ST will be set to 0 if negative.
string REPLACE(string SRC, PATTERN, string REPL)
Replaces all occurrences of PATTERN in SRC by REPL and returns the result. REPL can be omitted and defaults to the empty string. If the ï¬rst argument is an array of strings, each element in the array is replaced. The arguments PATTERN and REPL have to be scalar values. PATTERN can be a string or a regular expression (see below). For example:
REPLACE("abcdab", "ab") results in cd
REPLACE("abcdab", REGEX("^ab"), "xyz") results in xyzcdab

4.10.2 Regex functions

Apart from using regex/pattern constants, it is possible to use functions to form a regex or pattern. These functions can only be used on a scalar argument.

regex REGEX(string)
Handle the given string as a regular expression.
regex PATTERN(string)
Handle the given string as a UNIX ï¬lename-like pattern and convert it to a regular expression.
regex SQLPATTERN(string)
Handle the given string as an SQL-style pattern and convert it to a regular expression.

A regex formed this way can only be used in a comparison == or !=. E.g.
object == pattern(’3C*’)
to ï¬nd all 3C objects in a catalogue.

A few remarks:

  1. The regex/pattern functions and operator LIKE work on any string, thus they can be used with any string expression.
  2. A Regex is case sensitive. One should use function upcase or downcase on the string to test to make it case insensitive or use the i qualiï¬er on a regex constant.
  3. Usually a regex/pattern must match the full string, thus not part of it. However, one can use the m// regex constant to do partial matching. Thus something like m/xx/ matches all strings containing xx. Of course, regex(’.*xx.*’) can also be used. In this way the m// regex works the same as in languages like Perl, Python, and Glish.

4.10.3 Date/time functions

These functions make it possible to handle dates/times and can be used on a scalar or an array argument. The syntax of a date/time string or constant is explained in section 4.3.7.

DateTime DATETIME(string)
Parse the string and convert it to a DateTime value.
DateTime MJDTODATE(real)
The real value, which has to be a MJD (Modiï¬edJulianDate), is converted to a DateTime.
double MJD(DateTime)
Get the DateTime as MJD (Modiï¬edJulianDate) in days.
DateTime DATE(DateTime)
Get the date (i.e., remove the time part). This function is needed in something like:
DATE(column) == 12Feb1997
if the column contains date/times with times >0.
double TIME(DateTime)
Get the time part of the day. It is converted to radians to be compatible with the internal representation of times/positions. In that way the function can easily be used as in:
TIME(date) > 12h
integer YEAR(DateTime)
Get the year (which includes the century).
integer MONTH(DateTime)
Get the month number (1-12).
integer DAY(DateTime)
Get the day number (1-31).
integer WEEK(DateTime)
Get the week number in the year (0 ... 53).
Note that week 1 is the week containing Jan 4th.
integer WEEKDAY(DateTime), integer DOW(DateTime)
Get the weekday number (1=Monday, ..., 7=Sunday).
string CDATETIME(DateTime), string CTOD(DateTime)
Get the DateTime as a string like YYYY/MM/DD/HH:MM:SS.SSS.
string CDATE(DateTime)
Get the date part of a DateTime as a string like DD-MMM-YYYY.
string CTIME(DateTime)
Get the time part of a DateTime as a string like HH:MM:SS.SSS.
string CMONTH(DateTime)
Get the abbreviated name of the month (Jan ... Dec).
string CWEEKDAY(DateTime), string CDOW(DateTime)
Get the abbreviated name of the weekday (Mon ... Sun).

All functions can be used without an argument in which case the current date/time is used. e.g., DATE() results in the current date.
It is possible to give a string argument instead of a date. In this case the string is parsed and converted to a date (i.e., the function DATETIME is used implicitly).
Note that the function STR discussed in the next section can also be used for pretty-printing a date/time. It gives more control over the number of decimals and date format.

4.10.4 Pretty printing functions

Angles (scalar or array) can be returned as strings in HMS and/or DMS format. Currently, they are always formatted with 3 decimals in the seconds.

string HMS(real)
Return angle(s) like 12h34m56.789
string DMS(real)
Return angle(s) like 12d34m56.789
string HDMS(realarray)
Return angles like 12h34m56.789 (even elements) and 12d34m56.789 (odd elements). It is useful for arrays containing RA,DEC values.

The functions mentioned above and the date/time functions in the previous subsection can format a value in a predeï¬ned way only.
The STRING (shorthand STR) function makes it possible to convert values to strings using an optional format string or width.precision value. It also makes it possible to format dates, times, and angles in a variety of ways.

string STR(value, [format]), string STRING(value, [format])

The value can be of any type (except Regex) and can be a scalar or array. The optional format must be a scalar string or numeric value. If no format is given, an appropriate default format will be used.

  • A numeric format value deï¬nes the width and/or precision. For example:
      8        defines width 8 and default precision  
      20.12    defines width 20 and precision 12  
      .8       defines precision 8 and default width

    In this way precision represents all digits, not only the ones behind the decimal point. A default width or precision is used if not given.

  • A string format value can contain a printf-style format string, which must include the %-sign. Note that the real and imaginary part of a complex value are formatted separately, so such a format string needs to contain a format speciï¬er for both parts. See printf reference for possible format speciï¬ers. For example:
      %10d     decimal with width 10  
      %010d    decimal with width 10 and filled with zeroes  
      %f+%fi   to format a complex value as a+bi

    Apart from a printf-style format string, it is also possible to deï¬ne a string to format date/time and angle values (which are automatically converted to radians if containing units).
    Such a format string contains one or more format values as deï¬ned in class MVTime. A vertical bar (with optional whitespace) must be used as separator. A string part can be a numeric value deï¬ning the precision of the time/angle. Default precision is 6 (thus hh:mm:ss). The optional time/angle formats and modiï¬ers are:

    Format Description


    YMD yyyy/mm/dd/hh:mm:ss.sss
    YMD_ONLY YMD without the time (same as YMD|NO_TIME)
    DMY dd-Mon-yyyy/hh:mm:ss.sss
    FITS yyyy-mm-ddThh:mm:ss.sss
    BOOST the same as DMY|USE_SPACE
    NO_H, NO_D suppress the output of hours (or degrees): useful for offsets
    NO_HM, NO_DMsuppress the degrees and minutes
    CLEAN suppress leading or trailing periods or colons if not all time/angle parts
    are printed (e.g., when giving NO_H or 4 decimals)
    DAY precede the output with Day- (e.g., Wed-)
    NO_TIME suppress printing of time
    ANGLE +ddd.mm.ss.ttt
    TIME hh:mm:ss.ttt
    USE_SPACE use a space between date and time (and day and date)
    DIG2 get angle/time in range -90:+90 or -12:+12
    LOCAL local time; in FITS mode append time zone as +hh:mm

    For example:

      YMD             format as YYYY/MM/DD/HH:MM:SS  
      DMY|NO_TIME     format as DD-MMM-YYYY  
      DMY | DAY | 8   format as Thu-DD-MMM-YYY/HH:MM:SS.SS  
      TIME            format a datetime or angle as HH:MM:SS  
      ANGLE|9         format an angle as DD.MM.SS.SSS

    If such a format string contains an invalid part, it is assumed that the entire string is a printf-style format string.

4.10.5 Comparison functions

The exact comparison of floating point values is quite tricky. Two functions make it possible to compare 2 double or complex values with a tolerance. They can be used on scalar and array arguments (and a mix of them). The tolerance must be a scalar though.
Note that operator  = is the same as NEAR with a tolerance of 1e-5.

bool NEAR(numeric val1, numeric val2, double tol)
Tests in a relative way if a value is near another. Relative means that the magnitude of the numbers is taken into account.
It returns abs(val2 - val1)/max(abs(val1),abs(val2)) < tol.
If tol<=0, it returns val1==val2. If either val is 0.0, it takes care of area around the minimum number that can be represented. The default tolerance is 1.0e-13.
bool NEARABS(numeric val1, numeric val2, double tol)
Tests in an absolute way if a value is near another. Absolute means that the magnitude of the numbers is not taken into account.
It returns abs(val2 - val1) < tol. The default tolerance is 1.0e-13.
bool ISNAN(numeric val)
Tests if a numeric value is a NaN (not-a-number).
bool ISINF(numeric val)
Tests if a numeric value is inï¬nite (positive or negative).
bool ISFINITE(numeric val)
Tests if a numeric value is a ï¬nite number (not NaN or inï¬nite).

4.10.6 Mathematical functions

Standard mathematical can be used on scalar and array arguments (and a mix of them).

double PI()
Return the value of pi.
double E()
Return the value of e (is equal to EXP(1)).
double C()
Return the value of the speed of light (with unit m/s).
dnumeric SIN(numeric)
dnumeric SINH(numeric)
double ASIN(real)
dnumeric COS(numeric)
dnumeric COSH(numeric)
double ACOS(real)
double TAN(real)
double TANH(real)
double ATAN(real)
double ATAN2(real y, real x)
Return ATAN(y/x) in correct quadrant.
dnumeric EXP(numeric)
dnumeric LOG(numeric)
Natural logarithm.
dnumeric LOG10(numeric)
dnumeric POW(numeric, numeric)
The same as operator **.
numeric SQUARE(numeric), numeric SQR(numeric)
The same as **2, but much faster.
dnumeric SQRT(numeric)
complex COMPLEX(real, real)
dnumeric CONJ(numeric)
double REAL(numeric)
Real part of a complex number. Returns argument if real.
double IMAG(numeric)
Imaginary part of a complex number. Returns 0 if argument is real.
real NORM(numeric)
real ABS(numeric), real AMPLITUDE(numeric)
double ARG(numeric), double PHASE(numeric)
numeric MIN(numeric, numeric)
numeric MAX(numeric, numeric)
real SIGN(real)
Return -1 for a negative value, 0 for zero, 1 for a positive value.
real ROUND(real)
Return the rounded value of the number. Negative numbers are rounded in an absolute way. e.g., ROUND(-1.6) = -2.
real FLOOR(real)
Works towards negative inï¬nity. e.g., FLOOR(-1.2) = -2.
real CEIL(real)
Works towards positive inï¬nity.
real FMOD(real, real)
The same as operator %.

Note that the arguments or results of the trigonometric functions are in radians. They are converted automatically if units are given.

4.10.7 Array to scalar reduce functions

The following functions reduce an array to a scalar. They are meant for an array, but can also be used for a scalar.

bool ANY(bool)
Is any element true?
bool ALL(bool)
Are all elements true?
integer NTRUE(bool)
Return number of true elements.
integer NFALSE(bool)
Return number of false elements.
numeric SUM(numeric)
Return sum of all elements.
numeric SUMSQUARE(numeric), numeric SUMSQR(numeric)
Return sum of all squared elements.
numeric PRODUCT(numeric)
Return product of all elements.
real MIN(real)
Return minimum of all elements.
real MAX(real)
Return maximum of all elements.
dnumeric MEAN(numeric), dnumeric AVG(numeric)
Return mean of all elements.
double VARIANCE(real)
Return variance (the sum of
(a(i) - mean(a))**2/(nelements(a) - 1).
double STDDEV(real)
Return standard deviation (the square root of the variance).
double AVDEV(real)
Return average deviation. (the sum of
abs(a[i] - mean(a))/nelements(a).
double RMS(real)
Return root-mean-squares. (the square root of the sum of
(a(i)**2)/nelements(a).
double MEDIAN(real)
Return median (the middle element). If the array has an even number of elements, the mean of the two middle elements is returned.
double FRACTILE(real, doublescalar fraction)
Return the value of the element at the given fraction. Fraction 0.5 is the same as the median, but no mean of the two middle elements is taken.

4.10.8 Array to array reduce functions

These functions reduce an array to a smaller array by collapsing the given axes using the given function. The axes are the last argument(s). They can be given in two ways:
- As a single set argument; for example, maxs(ARRAY,[1,2])
- As individual scalar arguments; for example, maxs(ARRAY,1,2)
For example, using MINS(array,0,1) for a 3-dim array results in a 1-dim array where each value is the minimum of each plane in the cube.
It is important to note that the interpretation of the axes numbers depends on the style being used. e.g., when using glish style, axes numbers are 1-based and in Fortran order, thus axis 1 is the most rapidly varying axis. When using python style, axis 0 is the most slowly varying axis.
Axes numbers exceeding the dimensionality of the array are ignored. For example, maxs(ARRAY,[1:10]) works for arrays of virtually any dimensionality and results in a 1-dim array.
The function names are the ’plural’ forms of the functions in the previous section. They can only be used for arrays, thus not for scalars.

bool ANYS(bool)
Is any element true?
bool ALLS(bool)
Are all elements true?
integer NTRUES(bool)
Return number of true elements.
integer NFALSES(bool)
Return number of false elements.
numeric SUMS(numeric)
Return sum of elements.
numeric SUMSQUARES(numeric), numeric SUMSQRS(numeric)
Return sum of squared elements.
numeric PRODUCTS(numeric)
Return product of elements.
real MINS(real)
Return minimum of elements.
real MAXS(real)
Return maximum of elements.
dnumeric MEANS(numeric), dnumeric AVGS(numeric)
Return mean of elements.
double VARIANCES(real)
Return variance (the sum of
(a(i) - mean(a))**2/(nelements(a) - 1).
double STDDEVS(real)
Return standard deviation (the square root of the variance).
double AVDEVS(real)
Return average deviation. (the sum of
abs(a(i) - mean(a))/nelements(a).
double RMSS(real)
Return root-mean-squares. (the square root of the sum of
(a(i)**2)/nelements(a).
double MEDIANS(real)
Return median (the middle element). If the array has an even number of elements, the mean of the two middle elements is returned.
double FRACTILES(real, doublescalar fraction)
Return the value of the element at the given fraction. Fraction 0.5 is the same as the median.

4.10.9 Array downsampling functions

These functions are a generalization of the functions in the previous section. They downsample an array by taking, say, the mean of every n*m elements. The functions in the previous section downsample by taking the mean of a full line or plane, etc. The most useful one is probably calculating the boxed mean, but the other ones can be used similarly. The width of each window axis has to be given. Missing axes default to 1. Similarly to the partial reduce functions described above, the axes can be given as scalars or as a set.
For example, BOXEDMEAN(array,3,3) calculates the mean in each 3x3 box. At the end of an axis the box used will be smaller if it does not ï¬t integrally.
The functions can only be used for arrays, thus not for scalars.

bool BOXEDANY(bool)
Is any element true?
bool BOXEDALL(bool)
Are all elements true?
double BOXEDMIN(real)
Return minimum of elements.
double BOXEDMAX(real)
Return maximum of elements.
dnumeric BOXEDMEAN(numeric), dnumeric BOXEDAVG(numeric)
Return mean of elements.
double BOXEDVARIANCE(real)
Return variance (the sum of
(a(i) - mean(a))**2/(nelements(a) - 1).
double BOXEDSTDDEV(real)
Return standard deviation (the square root of the variance).
double BOXEDAVDEV(real)
Return average deviation. (the sum of
abs(a(i) - mean(a))/nelements(a).
double BOXEDRMS(real)
Return root-mean-squares. (the square root of the sum of
(a(i)**2)/nelements(a).
double BOXEDMEDIAN(real)
Return median (the middle element).

4.10.10 Array functions operating in running windows

These functions transform an array into an array with the same shape by operating on a rectangular window around each array element. The most useful one is probably calculating the running median, but the other ones can be used similarly. The half-width of each window axis has to be given; the full width is 2*halfwidth + 1. Missing axes default to a half-width of 0. Similarly to the partial reduce functions described above, the axes can be given as scalars or as a set.
For example, RUNNINGMEDIAN(array,1,1) calculates the median in a 3x3 box around each array element. See the examples how it is applied to an image.
In the result the edge elements (i.e., the elements where no full window can be applied) are set to 0 (or False).
The functions can only be used for arrays, thus not for scalars.

bool RUNNINGANY(bool)
Is any element true?
bool RUNNINGALL(bool)
Are all elements true?
double RUNNINGMIN(real)
Return minimum of elements.
double RUNNINGMAX(real)
Return maximum of elements.
dnumeric RUNNINGMEAN(numeric), dnumeric RUNNINGAVG(numeric)
Return mean of elements.
double RUNNINGVARIANCE(real)
Return variance (the sum of
(a(i) - mean(a))**2/(nelements(a) - 1).
double RUNNINGSTDDEV(real)
Return standard deviation (the square root of the variance).
double RUNNINGAVDEV(real)
Return average deviation. (the sum of
abs(a(i) - mean(a))/nelements(a).
double RUNNINGRMS(real)
Return root-mean-squares. (the square root of the sum of
(a(i)**2)/nelements(a).
double RUNNINGMEDIAN(real)
Return median (the middle element).

4.10.11 Type conversion functions

Explicit type conversions can be done using one of the functions below. They can operate on scalars and arrays.

integer INT(numeric or bool or string)
Convert the argument to an integer. A real number is truncated (-10.9 results in -10). For a complex number the truncated real part is taken. A bool is converted to 0 (False) or 1 (True). It does not check if a string represents a valid integer. It is interpreted until the ï¬rst non-valid character, so a string containing a floating point value is truncated.
double REAL(numeric or bool or string)
Convert the argument to a real number. For a complex number the real part is taken. A bool is converted to 0 (False) or 1 (True). It does not check if a string represents a valid floating point value. A string is interpreted until the ï¬rst non-valid character.
complex COMPLEX(real,real)
Form a complex number from the given real and imaginary part.
complex COMPLEX(string)
Convert the string to a complex number. The number can be given like (1,2) or 1+2i. In fact, any separator (except whitespace) between real and imaginary part is possible. It does not check if a string represents a valid complex value. The string is interpreted until the ï¬rst non-valid character, so the last character can be any character (e.g., also j).
bool BOOL(anytype)
Convert the value to a bool. A numeric type (or date) results in False if the value is 0, otherwise True. A string is case-insensitive. False, F, No, N, -, or 0 results in False, otherwise True.

4.10.12 Array creation functions

anytypearray ARRAY(anytype,shape)
This function creates an unmasked array of the given type and shape. The shape is given in the last argument(s). It can be given in two ways:
- As a single set argument; for example, array(0,[3,4])
- As individual scalar arguments; for example, array(0,3,4)
The ï¬rst argument gives the values the array is ï¬lled with. It can be a scalar or an array of any shape. To initialize the created array, the value array is flattened to a 1D array. Its successive values are stored in the created array. If the new array has more values than the value array, the value array is reset to its beginning and the process continues.
Note that a masked array can be created from an (unmasked) array and a mask using the brackets operator like ARRAY[MASK].
anytypearray MARRAY(anytypearray,boolarray)
This function offers another way to create a masked array. The mask must be given in the second argument; its shape must be the same as the shape of the data array.
anytypearray NULLARRAY(anytype)
This function creates a null array. Its data type is determined by the data type of the argument. The argument value itself is not used. It is mainly meant for test purposes.
anytypearray RESIZE(anytypearray,shape[,mode])
This function resizes an array to the given shape and copies the values. The optional mode argument determines how the values are copied. If the argument is not given, the new shape is arbitrary and the dimensionality can change. The values are copied to the same index in the new array. If an axis gets larger, the new values are set to 0 (or an empty string).
If mode is given, the new shape is much more restricted. The dimensionality cannot change and each axis has to be a multiple of the old one. If mode=0, copying the values is done in an upsampling way. E.g., if a new axis is twice the length of the old one, values 1,2,3 are copied as 1,1,2,2,3,3. A good use case is applying the flags of averaged data to the original data. If mode=1, the values in the example above are copied repeatedly as 1,2,3,1,2,3. By giving the mode as a set, it is possible to specify the mode per axis, but that is quite esoteric.
anytypearray TRANSPOSE(anytypearray[,axes])
This function transposes an N-dim array. If no axes are given, the array is fully transposed (thus all axes are reversed). Axes can be speciï¬ed meaning that those axes will become the ï¬rst axes in the output array. Non-given axes follow thereafter in their natural order.
A possible mask is transposed as well.
anytypearray DIAGONAL(anytypearray[,firstaxis[,diag]])
This function takes the diagonal of 2-dim subarrays in an N-dim array resulting in an array with 1 dimension less. For a 2-dim array, it is simply the diagonal of the matrix. For a higher dimensional array, it takes the diagonal of each matrix deï¬ned by firstaxis and firstaxis+1. e.g., in a 3-dim array the diagonals of each XY-plane can be taken. The default for ï¬rstaxis is 0.
The diag argument tells which diagonal has to be taken. The default 0 means the main diagonal. A negative value means below the main diagonal, while positive means above the main diagonal.
anytypearray ARRAYDATA(anytype)
This function returns the array without a mask, thus removes the mask. If the operand is a scalar, it returns a 1-dim array with one element.
anytypearray NEGATEMASK(anytype)
This function returns the array with the negated mask. If the array has no mask, it returns the array with a mask of all Trues. If the operand is a scalar, it returns a 1-dim array with one element.
anytypearray REPLACEMASKED(anytype, anytype)
This function replaces the masked elements in the ï¬rst argument by the corresponding value in the second argument (which can be a scalar value). If the ï¬rst argument has no mask, the function is a no-op.
anytypearray REPLACEUNMASKED(anytype, anytype)
This function replaces the unmasked elements in the ï¬rst argument by the corresponding value in the second argument (which can be a scalar value). If the ï¬rst argument has no mask, the function is a no-op.
boolarray ARRAYMASK(anytype), boolarray MASK(anytype)
This function returns the mask of an array. If the array has no mask, it returns a boolean array of the same shape with all values set to False. If the operand is a scalar, it returns an 1-dim array with one False element.
anytypearray FLATTEN(anytype)
This function flattens an N-dim array to a 1-dim array keeping the unmasked elements only. If the operand is a scalar, it returns a 1-dim array with one element.

4.10.13 Aggregate functions

The GXXX aggregate functions calculate an aggregated value for all rows in a group, usually deï¬ned with a GROUPBY clause. For example, when grouping in TIME, an aggregate function like GNTRUE(FLAG) counts per time slot the number of flagged data points. Aggregate functions can only be used in the SELECT and the HAVING clause.
Most functions listed below reduce the values in a group to a scalar value, also if the value in a row is an array (as in the GNTRUE example above). The arrays in a group can have different shapes.

However, there are several aggregate functions returning an array as done by the last three functions (GHIST, GAGGR, and GROWID) shown below. Furthermore, most scalar functions have a plural form (e.g., GNTRUES) returning an array. They are described at the end of this section.

Note that the aggregate function names differ from their SQL counterparts; they all have the preï¬x G, because TaQL functions like MAX already exist for array operations. This naming scheme also makes it more clear which TaQL functions are aggregate functions.

A technical detail is how aggregate functions are implemented. TaQL walks sequentially through a table. Non-lazy functions operate directly on the value in a row making the table access purely sequential. It requires that the results of all groups are held in memory. For some functions, in particular GAGGR, this could lead to a very high memory usage. Therefore, some functions are implemented in a lazy way. They keep the row numbers of a group and access the data when the aggregated result of a group is needed. In this way only the data of a single group needs to be held in memory, but the access to the table might be non-sequential making it somewhat slower. Currently, only GAGGR and the User Deï¬ned aggregate functions are implemented in a lazy way.

integer GCOUNT(), integer GCOUNT(*)
Return the number of rows per group.
integer GCOUNT(columnname)
Return the number of rows per group for which the column has a value. Note that only a column containing variable sized arrays can contain empty cells.
anytype GFIRST(anytype)
Return the ï¬rst value of an expression in the group. The values of a column not mentioned in the GROUPBY clause, might differ. This function can be used to return the value of the ï¬rst row in the group.
anytype GLAST(anytype)
Return the last value of the group (is similar to GFIRST).
Note this function is implicitly used if an expression without aggregate function is used in a group.
bool GANY(bool)
Is any element true?
bool GALL(bool)
Are all elements true?
integer GNTRUE(bool)
Return number of true elements.
integer GNFALSE(bool)
Return number of false elements.
numeric GSUM(numeric)
Return sum of all elements.
numeric GSUMSQUARE(numeric), numeric GSUMSQR(numeric)
Return sum of all squared elements.
numeric GPRODUCT(numeric)
Return product of all elements.
real GMIN(real)
Return minimum of all elements.
real GMAX(real)
Return maximum of all elements.
dnumeric GMEAN(numeric), dnumeric GAVG(numeric)
Return mean of all elements.
double GVARIANCE(real)
Return variance (the sum of
(a(i) - mean(a))**2/(nelements(a) - 1).
double GSTDDEV(real)
Return standard deviation (the square root of the variance).
double GAVDEV(real)
Return average deviation. (the sum of
abs(a[i] - mean(a))/nelements(a).
double GRMS(real)
Return root-mean-squares. (the square root of the sum of
(a(i)**2)/nelements(a).
double GMEDIAN(real)
Return median (the middle element). If the array has an even number of elements, the mean of the two middle elements is returned.
double GFRACTILE(real, doublescalar fraction)
Return the value of the element at the given fraction. Fraction 0.5 is the same as the median.
double GHIST(real, intscalar nbin, realscalar start, realscalar end)
Return the histogram of the data using the given number of bins. The histogram contains an extra bin at the beginning and the end for the outliers. If the rows in the group contain arrays, they can have variable shapes.
anytypearray GAGGR(anytype), anytypearray GSTACK(anytype)
Stack the row values in a group to form an array where the row is the slowest varying axis (similar to numpy’s dstack). Thus if the column contains scalar values, the result is a vector. Otherwise it is an array whose dimensionality is one higher. It requires that all arrays in a group have the same shape.
Note that this function can be very useful for arrays, because it makes it possible to use partial reduce functions like medians to calculate the medians along arbitrary axes.
integerarray GROWID()
Return the row numbers of the rows in the group.

Most functions above have a plural counterpart. They calculate the aggregated value per array index, thus the result has the same shape as the arrays in the group. Similar to function GAGGR, they require that all arrays in a group have the same shape.
For instance, for a MeasurementSet the expression GMEANS(DATA) calculates the mean in a group per channel/polarization. Not only it is a shorthand for MEANS(GAGGR(DATA), 0), but it usually works faster because, unlike GAGGR, it is non-lazy.
The functions available are:

  GANYS   GALLS      GNTRUES     GNFALSES  
  GMINS   GMAXS  
  GSUMS   GPRODUCTS  GSUMSQRS    GSUMSQUARES  
  GMEANS  GAVGS      GVARIANCES  GSTDDEVS  GRMSS

4.10.14 Miscellaneous functions

bool ISNULL(anytype)
Return True if the argument value is a null array.
bool ISDEFINED(anytype)
Return False if the array value in the current row is undeï¬ned (is null). It makes it possible to test if a cell in a column with variable shaped arrays contains an array. Furthermore, it can be used to test if a ï¬eld in a record is deï¬ned.
Note that function ISNULL can also be used to test for an undeï¬ned array in a row.
bool sh.ISCOLUMN(string)
Return False if no column with the given name exists in the table with the shorthand given before the function name. If no table is given, the ï¬rst one will be used.
bool sh.ISKEYWORD(string)
Return False if no keyword with the given name exists in the table with the shorthand given before the function name. If no table is given, the ï¬rst one will be used. The keyword name can be given as described in section 4.5, thus the name of a table keyword or column keyword or a nested ï¬eld can be speciï¬ed.
integer NELEMENTS(anytype), integer COUNT(anytype)
Return number of elements in an array (1 for a scalar).
integer NDIM(anytype)
Return dimensionality of an array (0 for a scalar).
integerarray SHAPE(anytype)
Return shape of an array (returns an empty array for a scalar).
integer ROWNUMBER(), integer ROWNR()
Return the row number being tested (ï¬rst row is row number 0 or 1 depending on the style used).
In combination with function RAND it can, for instance, be used to select arbitrary rows from a table.
integer ROWID()
Return the row number in the original table. This is especially useful for returning the result of a selection of a subtable of a Casacore measurement set (see also subqueries in 4.11 and examples in section 12.1).
double RAND()
Return (per table row) a uniformly distributed random number between 0 and 1 using a Multiplicative Linear Congruential Generator. The seeds for the generator are deduced from the current date and time, so the results are different from run to run.
The function can, for instance, be used to select a random subset from a table.
double ANGDIST(arg1,arg2), double ANGULARDISTANCE(arg1,arg2)
Return the angular distance (in radians) between the positions in arg1 and arg2. Both arguments have to be numeric arrays containing an even number of values. Two subsequent values give the RA and DEC (or longitude and latitude) of positions on a sphere. The result is a 1-dim array containing the angular distance between corresponding positions in arg1 and arg2. If either array contains only one position, the result is the distance between that position and each position in the other array. If both arguments contain only 2 values, the result is a scalar. For example:
angdist(PHASE_DIR[0,], [12h13m45,4d21m39.4, 12h13m49,10d8m4])
returns an array with shape [2] containing the angular distance between the phase center of the ï¬eld and the two positions given.
double ANGDISTX(arg1,arg2), double ANGULARDISTANCEX(arg1,arg2)
Same as above, but the result is a 2-dim array giving the distance between each position in the ï¬rst argument and each position in the second argument. Only if both arguments contain a single position, the result is a scalar.
anytype IIF(cond,arg1,arg2)
This is a special funtion which operates like the ternary ?: operator in C++. If all arguments are scalars, the result is a scalar, otherwise an array. In the latter case possible scalar arguments are virtually expanded to arrays. IIF evaluates the condition for each element. If True, it takes the corresponding element of arg1, otherwise of arg2.
If one of the input arrays has a mask, the output array will also have a mask. Each output mask element value is the logical OR of the condition mask element value and the mask value of the element taken from arg1 or arg2.

4.10.15 Cone search functions

Cone search functions make it possible to test if a source is within a given distance of a given sky position. The expression

  cos(0d1m) < sin(52deg) * sin(DEC) +  
              cos(52deg) * cos(DEC) * cos(3h30m - RA)

could be used to test if sources with their sky position deï¬ned in columns RA and DEC are within 1 arcmin of the given sky position.
The cone search functions implement this expression making life much easier for the user. Because they can also operate on arrays of positions, searching in multiple cones can be done simultaneously. That makes it possible to ï¬nd matching source positions in two catalogues as shown in an example at the end of this section.

The arguments of all functions are described below. All of them have to be given in radians. However, usually one does not need to bother because TaQL makes it possible to specify positions in many formats automatically converted to radians.

SOURCES
is a set or array giving the positions of one or more sources (e.g., in equatorial coordinates) to be tested. Normally these are columns in a table. Where argument name SOURCE is mentioned below, only a single source can be used, otherwise multiple sources.
For example:
[RA,DEC] for scalar columns RA and DEC.
SKYPOS for a column SKYPOS containing 2-element vectors with RA and DEC.
CONES
is a set or array giving the center positions and radii of one or more cones (e.g., as RA,DEC,radius). Usually the user will specify it as constants.
For example:
[12h13m54, -5.3.34, 0d1m] for a single cone.
[12h13m54, -5.3.34, 0d1m, 1h2m3, 4.5.6, 0d1m] for two cones.
CONEPOS
is a set or array giving the positions of one or more cone centers (e.g., as RA,DEC).
RADII
is a scalar, set or array giving one or more radii. Each radius is applied to all positions in CONEPOS. Specifying a cone as CONEPOS,RADIUS is easier than specifying it as CONES if the same radius has to be used for multiple cones.
For example:
[12h13m54, -5.3.34, 1h2m3, 4.5.6], 0d1m is the same as the second CONES example above.

The following cone search functions are available.

bool ANYCONE(SOURCE,CONES)
Return T if the source is contained in at least one of the cones. Operator INCONE is a synonym. So ANYCONE(SOURCE,CONES) is the same as SOURCE INCONE CONES.
bool ANYCONE(SOURCE,CONEPOS,RADII)
It does the same as above.
integer FINDCONE(SOURCES,CONES)
Return the index of the ï¬rst cone containing the source. If a single source is given, the result is a scalar. If multiple sources are given, the result is an array with the same shape as the source array.
integer FINDCONE(SOURCES,CONEPOS,RADII)
It does the same as above. Note that in this case each radius is applied to each cone, so the resulting index array is a combination of the two input arrays (with the radius as the most rapidly varying axis).
bool CONES(SOURCES,CONES)
Return a 2-dim bool array. The length of the most rapidly varying axis is the number of cones. The length of the other axis is the number of sources. When using python style, element (i,j) in the resulting array is T if source i is contained in cone j.
bool CONES(SOURCES,CONEPOS,RADII)
It does the same as above. However, the result is a 3-dim array with the radii as the most rapidly varying axis, cones as the next axis, and sources as the slowest axis.

Please note that ANYCONE(SOURCE,CONES) does the same as any(CONES(SOURCE,CONES)), but is faster because it stops as soon as a cone is found.
Function CONES makes it possible to do catalogue matching. For example, to ï¬nd sources matching other sources in the same catalogue (within a radius of 10 arcseconds):

  CALC CONES([RA,DEC],  
             [SELECT FROM table.cat GIVING [RA,DEC]], 0d0m10)  
     FROM table.cat

Note that in this example the SELECT clause returns an array with positions which are used as the cone centers. So each source in the catalogue is tested against every source. It makes it an N-square operation, thus potentially very expensive. The result is a 4-dim boolean array with shape (in glish style) [1,nrow,1,nrow] which can be processed in Glish. Please note that the CONES function results for each row in a array with shape [1,nrow,1].
The query can be done with multiple radii, for example also with 1 arcsecond and 1 arcminute.

  CALC CONES([RA,DEC],  
       [SELECT FROM table.cat GIVING [RA,DEC]], [0d0m1, 0d0m10, 0d1m])  
     FROM table.cat

resulting in an array with glish shape [3,nrow,1,nrow]. In this way one can get a better indication how close sources are to the cone centers.

4.10.16 User deï¬ned functions

TaQL can be extended with so-called User Deï¬ned Functions (UDF). These are dynamically loaded functions, either written in C++ or in Python. In TaQL the name of a UDF written in C++ consists of the name of the library (without lib preï¬x and extension) followed by a dot and the function name. For example:

  meas.hadec(...)

denotes function hadec in shared library libmeas.so or libcasa_meas.so. For OS-X the extension .dylib will be used.
The physical shared library name must be fully lowercase, but the UDF name used in TaQL is case-insensitive. The name of a UDF written in Python is like py.module.func where the module part is optional. In the USING STYLE clause it is possible to deï¬ne synonyms for the UDF library names. By default, mscal is deï¬ned as a synonym for derivedmscal and py as a synonym for pytaql.

Usually a UDF will operate on the arguments given to the function and will not itself operate on a table given in a query command. However, some UDFs (most notably the mscal ones) do not have arguments, but operate directly in a speciï¬c way on a table. Normally they use the ï¬rst table given in the FROM clause, but the UDF name can be preceded by a table shorthand to specify another table. For example:

  select t1.mscal.ha1(), t2.mscal.ha1() from my1.ms t1, my2.ms t2

to get the hourangle from two different tables. Of course, both tables need to have the same number of rows.
Note that UDFs not directly operating on a table, will ignore a shorthand.

In section Writing user deï¬ned functions it is explained how to write user deï¬ned functions.

4.10.17 Special MeasurementSet functions

The Casacore package comes with several predeï¬ned UDFs in library libcasa_derivedmscal. It contains four groups of UDFs, all operating on a MeasurementSet and several on a CASA calibration table (both old and new format).
Although the library is called derivedmscal, for ease of use it is possible to use the synonym mscal.

Get derived values
The ï¬rst group calculates derived values like hourangle and azimuth for the ï¬rst or second antenna of a baseline. For calibration tables, where a row contains a single antenna, functions like PA1 are the same as PA2. All angles are returned in radians.

double MSCAL.HA()
gives the hourangle of the array center (observatory position).
double MSCAL.HA1()
gives the hourangle of ANTENNA1.
double MSCAL.HA2()
gives the hourangle of ANTENNA2.
double MSCAL.HADEC()
gives the topocentric hourangle/declination of the array center (observatory position).
double MSCAL.HADEC1()
gives the topocentric hourangle/declination of ANTENNA1.
double MSCAL.HADEC2()
gives the topocentric hourangle/declination of ANTENNA2.
doublearray MSCAL.AZEL()
gives the topocentric azimuth/elevation of the array center (observatory position).
doublearray MSCAL.AZEL1()
gives the topocentric azimuth/elevation of ANTENNA1.
doublearray MSCAL.AZEL2()
gives the topocentric azimuth/elevation of ANTENNA2.
double MSCAL.LAST()
gives the local sidereal time of the array center.
double MSCAL.LAST1()
gives the local sidereal time of ANTENNA1.
double MSCAL.LAST2()
gives the local sidereal time of ANTENNA2.
double MSCAL.PA1()
gives the parallactic angle of ANTENNA1.
double MSCAL.PA2()
gives the parallactic angle of ANTENNA2.
doublearray MSCAL.NEWUVW()
gives the 3-vector of UVW coordinates in J2000 in meters. It recalculates them, thus does not return the UVW coordinates stored in the MeasurementSet.
doublearray MSCAL.NEWUVWWVL()
gives the 3-vector of calculated UVW coordinates in J2000 in wavelengths for the reference frequency of the appropriate spectral window.
doublearray MSCAL.NEWUVWWVLS()
gives the nfreq*3-matrix of calculated UVW coordinates in J2000 in wavelengths for all channel frequencies of the appropriate spectral window.
doublearray MSCAL.UVWWVL()
gives the 3-vector of stored UVW coordinates in wavelengths for the reference frequency of the appropriate spectral window.
doublearray MSCAL.UVWWVLS()
gives the nfreq*3-matrix of stored UVW coordinates in wavelengths for all channel frequencies of the appropriate spectral window.

By default all these functions will use the direction given in column PHASE_DIR of the FIELD subtable. It is possible to use another column by giving its name as a string argument (e.g., HA(’DELAY_DIR’)).
Except for the last 2 functions, it is possible to use an explicit direction which must be given as [RA,DEC] in J2000 or as a case-insensitive name of a planetary object (as deï¬ned by the Casacore Measures). For example:

   derivedmscal.azel1([5h23m32.76, 10d15m56.49])  
   derivedmscal.azel1(’MOON’)

The examples above give the azimuth and elevation of the given directions for each selected row in the MeasurementSet, using the position of ANTENNA1 and the times in these rows.

If a string value is given, it is ï¬rst tried as a planetary object. Theoretically it is possible that a column has the same name as a planetary object. In such a case the name can be escaped by a backslash to indicate that a column name is meant. For example:

   derivedmscal.azel1(’\SUN’)

means that column SUN in the FIELD table has to be used.

Stokes conversion
The STOKES function makes it possible to convert the Stokes parameters of a DATA column in a MeasurementSet, for instance from linear or circular to iquv. It is also possible to convert the weights or flags, i.e., to combine them in the same way as the data would be combined.

complexarray MSCAL.STOKES(complexarray, string)
converts the data.
doublearray MSCAL.STOKES(doublearray, string)
combines the weights.
boolarray MSCAL.STOKES(boolarray, string)
combines the flags.

In all cases the case-insensitive string argument deï¬nes the output Stokes axes. It must be a comma separated list of Stokes names. All values deï¬ned in the Casacore class Stokes are possible. Most important are:

  • XX, XY, YX, and/or YY.
    LINEAR or LIN means XX,XY,YX,YY.
  • RR, RL, LR, and/or LL.
    CIRCULAR or CIRC means RR,RL,LR,LL.
  • I, Q, U, and/or V.
    IQUV or STOKES means I,Q,U,V.
  • PTOTAL is the polarized intensity (sqrt(Q**2+U**2+V**2))
  • PLINEAR is the linearly polarized intensity (sqrt(Q**2+U**2))
  • PFTOTAL is the polarization fraction (Ptotal/I)
  • PFLINEAR is the linear polarization fraction (Plinear/I)
  • PANGLE is the linear polarization angle (0.5*arctan(U/Q)) (in radians)

If not given, the string argument defaults to ’IQUV’. For example:

  select mscal.stokes(DATA,’circ’) as CIRCDATA from my.ms

creates a table with column CIRCDATA containing the circular polarization data.

CASA style selection
The BASELINE function makes it possible to do selection on baselines in a MeasurementSet or CalTable using the special CASA selection syntax described in note 263. Similar functions CORR, TIME, FIELD, FEED, SCAN, SPW, UVDIST, STATE, OBS, and ARRAY can be used to do selection based on other meta data. The functions accept a string containing a selection string and return a Bool value telling if a row matches the selection string. For example,

  select from my.ms where mscal.baseline(’RT[2-4]’)

selects the cross-correlation baselines containing an antenna whose name matches the pattern in the function argument.
Note there is a difference how CASA and TaQL handle unknown antennas given in the baseline selection string. CASA tasks give an error, while TaQL will not complain and not even report it, because doing a selection this way should not behave differently from doing it like NAME=’RTX’.
Also note that in CASA tasks only one selection string per type can be given and the ï¬nal selection is the AND of them. TaQL has the AND and OR operators making it possible to combine the selections in all kind of ways, possibly using multiple selection strings of the same type.

Get values from a subtable
Several functions exist to get information like the name of an antenna from the subtable for each row in the main table. Basically they do a join of the main table and a subtable. For example:

  select mscal.ant1name(), mscal.ant2name() from my.ms

gets the names of the antennae used in each baseline.

The following functions can be used:

string MSCAL.ANT1NAME()
gives the name of ANTENNA1.
string MSCAL.ANT2NAME()
gives the name of ANTENNA2.
anytype MSCAL.ANT1COL(ColumnName)
gives for ANTENNA1 the value in the given column (in quotes) in the ANTENNA subtable.
anytype MSCAL.ANT2COL(ColumnName)
gives for ANTENNA2 the value in the given column (in quotes) in the ANTENNA subtable.
anytype MSCAL.STATECOL(ColumnName)
gives for STATE_ID the value in the given column (in quotes) in the STATE subtable.
anytype MSCAL.OBSCOL(ColumnName)
gives for OBSERVATION_ID the value in the given column (in quotes) in the OBSERVATION subtable.
anytype MSCAL.SPWCOL(ColumnName)
gives for DATA_DESC_ID the value in the given column (in quotes) in the SPECTRAL_WINDOW subtable.
anytype MSCAL.POLCOL(ColumnName)
gives for DATA_DESC_ID the value in the given column (in quotes) in the POLARIZATION subtable.
anytype MSCAL.FIELDCOL(ColumnName)
gives for FIELD_ID the value in the given column (in quotes) in the FIELD subtable.
anytype MSCAL.PROCCOL(ColumnName)
gives for PROCESSOR_ID the value in the given column (in quotes) in the PROCESSOR subtable.
anytype MSCAL.SUBCOL(SubtableName, ColumnName, idcolumn)
gives for the (integer) id-column the value in the given column in the given subtable. This is the most common form and can be used to join any table with a subtable.

Note that the following are equivalent. The ï¬rst versions are shorthands for the latter ones.

 mscal.ant1name()  
 mscal.ant1col(’NAME’)  
 mscal.subcol(’ANTENNA’, ’NAME’, ANTENNA1)

In the last example the id-column must be given as such, thus must not be a string.

4.10.18 Special Measures functions

These functions make it possible to convert measures like directions, epochs, and positions from one reference frame to another. All conversions supported by Casacore’s Measures are possible. For example:

  meas.galactic (-6h52m36.7, 34d25m56.1, "J2000")  
  meas.azel ("MOON", datetime(), "WSRT")

The ï¬rst example converts a J2000 position to galactic coordinates. The second example gives the moon’s azimuth/elevation at the WSRT at the current date/time.

The following basic functions are available. Most functions return double angle values with unit rad. Only the RISESET function returns date/time values.
Note that all names used below are case-insensitive.

doublearray MEAS.DIR(toref, direction, epoch, position)
converts a direction to the reference type given by the ’toref’ string. The epoch and position arguments only need to be given if the conversion needs frame information (e.g., when converting J2000 to apparent).
Function name MEAS.DIRECTION can be used as well.
doublearray MEAS.DIRCOS(toref, direction, epoch, position)
Same as function DIR, but returning 3 direction cosines instead of 2 angles.
Function name MEAS.DIRECTIONCOSINE can be used as well.
DateTimearray MEAS.RISESET(direction, epoch, position)
returns the rise and set date/times (UTC) of the sources given in the direction argument for the given dates and positions. Function name MEAS.RISET can be used as well. Note that the source can be invisible all day (results in set <rise). If visible all day, rise time is 0h0m and set time is 24 hours later.
The TIME or CTIME function can be used on the result to get the time part only (as double or string).
If the sun is used as a source name (case-insensitive), it can be followed by a hyphen and one of the following case-insensitive suffices indicating what to use. The default is CR which is used in most almanacs.
  • CR: use the center of the sun with refraction correction.
  • UR: use the upper brim of the sun with refraction correction, thus show when part of the sun is visible.
  • LR: use the lower brim of the sun with refraction correction, thus show when the full sun is visible.
  • C: use the center of the sun without refraction correction.
  • U: use the upper brim of the sun without refraction correction.
  • L: use the lower brim of the sun without refraction correction.
  • CT: use the civil twilight (6 deg). without artiï¬cal light.
  • NT: use the nautical twilight (12 deg). visible for navigating.
  • AT: use the amateur astronomical twilight (15 deg).
  • ST: use the scientiï¬c astronomical twilight (18 deg).

The ï¬rst six suffices can also be used with the Moon.
See stjarnhimlen.se for additional information.

doublearray MEAS.EPOCH(toref, epoch, position)
converts an epoch to the reference type given by the ’toref’ string. The position argument only needs to be given if the conversion needs frame information. By default conversions to sidereal time (e.g, LAST) return the fraction giving the true sidereal time. Only if the toref string starts with ’F-’, ’F_’, ’f-’, or ’f_’ the full sidereal time is returned which includes the number of sidereal days since the start of MJD.
doublearray MEAS.POS(toref, position)
converts a position to the reference type given by the ’toref’ string.
Function name MEAS.POSITION can be used as well.

The available reference types can be shown using the show meastypes command in the program taql. For ease of use several specialized MEAS.DIR and MEAS.POS functions are deï¬ned with an implicit ’toref’ argument.

doublearray MEAS.J2000(direction, epoch, position)
converts a direction to J2000.
doublearray MEAS.B1950(direction, epoch, position)
converts a direction to B1950.
doublearray MEAS.APP(direction, epoch, position)
converts a direction to apparent coordinates.
Function name MEAS.APPARENT can be used as well.
doublearray MEAS.HADEC(direction, epoch, position)
converts a direction to hourangle/declination.
doublearray MEAS.AZEL(direction, epoch, position)
converts a direction to azimuth/elevation.
doublearray MEAS.ECL(direction, epoch, position)
converts a direction to ecliptic coordinates.
Function name MEAS.ECLIPTIC can be used as well.
doublearray MEAS.GAL(direction, epoch, position)
converts a direction to galactic coordinates.
Function name MEAS.GALACTIC can be used as well.
doublearray MEAS.SGAL(direction, epoch, position)
converts a direction to supergalactic coordinates.
Function name MEAS.SUPERGAL or MEAS.SUPERGALACTIC can be used as well.
doublearray MEAS.ITRFD(direction, epoch, position)
converts a direction to ITRF coordinates.
Function name MEAS.ITRFDIR or MEAS.ITRFDIRECTION can be used as well.
doublearray MEAS.LAST(epoch, position)
converts an epoch to local sidereal time.
Function name MEAS.LST can be used as well.
doublearray MEAS.ITRFxxx(position)
converts a position to ITRF coordinates.
doublearray MEAS.WGSxxx(position)
converts a position to WGS84 coordinates.

The names of the last two functions have a suffix xxx indicating how positions are returned.
- XYZ means as x,y,z
- LL or LONLAT means as lon,lat
- H or HEIGHT means as height
It defaults to XYZ.

The function arguments can be given in a variety of ways.

  • ’toref’ is a constant scalar string giving the reference type to convert to. See the Measure classes MDirection, MEpoch, and MPosition, for an overview of the types.
  • ’direction’ gives one or more directions to convert. They can be given in several ways.
    • As a constant scalar or array of strings giving one or more planetary objects like MOON or VENUS and/or giving the name of standard sources (CasA, CygA, TauA, VirA, HerA, HydA, or PerA). In the future support for comets might be added.
      The names are case-insensitive.
    • As 2 constant double scalar arguments giving ra and dec (or longitude and latitude).
    • As a double array with an even number of elements giving ra/dec or longitude/latitude of one or more directions. It can be a constant array (expression), but it can also be a column or an expression using a column.

    If a column or a column slice is given, the reference type stored in the column keywords will be recognized. In other cases the input reference type should be given in the next string argument. If not given, it defaults to J2000.
    For example:

      [’MOON’,’sun’, ’venus’]          # 3 planetary objects  
      12h23m17.5, 23d56m43.8, ’B1950’  # ra/dec as scalar constants (as B1950)  
      [12h23m17.5, 23d56m43.8]         # ra/dec as array (default J2000)  
      PHASE_DIR[0,]                    # direction ra/dec in given column

  • ’epoch’ gives one or more epochs to use. Similar to directions the reference type is taken from the column keywords or can be given in the next argument. It defaults to UTC.
    Epochs can be given in three ways:
    • As a scalar or array containing double values. It can be a constant expression or a column (expression).
    • As a scalar or array containing DateTime values.
    • As a scalar or array containing String values representing date/time. They will automatically be converted to DateTime values using function datetime.

    For example:

      datetime()                         # current date/time  
      ’today’                            # current date/time  
      [select unique TIME from my.ms]    # all times from some MS  
      9Sep2011/12:00:00, ’UTC’           # given UTC time

    Note that in the last example ’UTC’ is not necessary, because it is the default.

  • ’position’ gives one or more directions to use. They can be given as x,y,z or as lon,lat with an optional height. Usually the unit of the ï¬rst value deï¬nes if x,y,z or lon,lat is used. It is, however, also possible to distinguish between LL and XYZ by using suffices like XYZ or LL in the reference type given in the next argument.
    • As a scalar or array of observatory names using their positions in the Measures Observatory table.
    • As 2 or 3 constant double scalar values giving xyz, lonlat, or lonlat/height.
    • As a double array giving one or more positions in xyz or lonlat. Similar to directions it can be a column (expression) where the reference type is taken from the column keywords.
    • As two constant double arrays giving lonlat and height of one or more positions. The array sizes have to match (thus the size of the lonlat array must be twice the size of the height array).

    If needed, the reference type (with optional suffix) can be given in the next argument. The reference type defaults to ITRF if xyz coordinates are used, otherwise to WGS.
    For example:

      ’WSRT’                             # WSRT position  
      5deg, 52deg                        # 2 scalar constants (WGS84 lonlat)  
      (5deg, 52deg]                      # same, but as array  
      5deg, 52deg, 5m                    # WGS84 lonlat with height  
      [5deg, 52deg], [5m]                # same, but as array  
      3.8288e+06m, 442449, 5.0649e+06    # xyz as scalars (ITRF)  
      [41.84m, 4.835, 55.722], ’WGS’     # xyz as array (WGS84)  
      POSITION                           # POSITION column

A few more elaborate examples are given below.

  meas.last (date(’15Oct2011/15:34’), 5deg, 52deg)

calculates the local apparent sidereal time for the given date and position.

  meas.azel ("JUPITER", [select unique TIME from ~/GER1.MS],  
            ["WSRT","VLA"])

calculates Jupiter’s azimuth/elevation for WSRT and VLA for all times returned by the subquery (see next section for subqueries).

  calc meas.b1950(PHASE_DIR[0,]) from ~/GER1.MS/FIELD’

converts the PHASE_DIR directions in the FIELD table to B1950. Note that no frame information is needed for such a conversion.

  meas.azel([03h13m10,65d50m12], 24sep2015/12:0:0+[0:24]h, ’LOFAR’) deg  
  meas.azel(03h13m10,65d50m12,’B1950’, 24sep2015/12:0:0+[0:24]h, ’LOFAR’)deg

calculates the azimuth/elevation (in degrees) of the given source direction for the LOFAR site for 24 hours. The result is an array with shape [24,2]. The direction in the second example is given in B1950, the ï¬rst as the default J2000.

4.11 Subqueries

As in SQL it is possible to create a set from a subquery. A subquery has the same syntax as a main query, but has to be enclosed in square brackets or parentheses. Basically it looks like:

  SELECT FROM maintable WHERE time IN  
      [SELECT time FROM othertable WHERE windspeed < 5]

The subquery on othertable results in a constant set containing the times for which the windspeed matches. Subsequently the main query is executed and selects all rows from the main table with times in that set. Note that like other bounded sets this set is transformed to a constant array, so it is possible to apply functions to it (e.g., min, mean).

  SELECT [SELECT NAME FROM ::ANTENNA][ANTENNA1] FROM ~/GER1.MS

This example shows how a subquery is used to join the main table of a MeasurementSet and its ANTENNA subtable. The subquery returns a list with the names of all antennae, which subsequently is indexed with the antenna number to get the antenna name for each row in the main table.

  SELECT mscal.ant1name() from ~/GER1.MS

is a newer and easier way to obtain the name of ANTENNA1. It makes use of the new user deï¬ned functions in derivedmscal which can do an implicit join of a MeasurementSet and its subtables.

  SELECT FROM maintable WHERE time IN  
      [SELECT time FROM othertable WHERE windspeed <  
           mean([SELECT windspeed FROM othertable])]

This example contains another subquery to get all windspeeds and to take the mean of them. So the ï¬rst subquery selects all times where the windspeed is less than the average windspeed.
A subquery result should contain only one column, otherwise an exception is thrown.

It may happen that a subquery has to be executed twice because 2 columns from the other table are needed. E.g.

  SELECT FROM maintable WHERE any(time >=  
      [SELECT starttime FROM othertable WHERE windspeed < 5]  
                               && time <=  
      [SELECT endtime FROM othertable WHERE windspeed < 5])

In this case the other table contains the time range for each windspeed. For big tables it is expensive to execute the subquery twice. A better solution is to store the result of the subquery in a temporary table and reuse it.

  SELECT FROM othertable WHERE windspeed < 5 GIVING tmptab  
  SELECT FROM maintable WHERE any(time >=  
      [SELECT starttime FROM tmptab]  
                               && time <=  
      [SELECT endtime FROM tmptab])

However, this has the disadvantage that the table tmptab still exists after the query and has to be deleted explictly by the user. Below a better solution for this problem is shown.

TaQL has a few extensions to support tables better, in particular the Casacore MeasurementSets.

  1. The temporary problem above can be circumvented by using the ability to use a SELECT expression in the FROM clause. E.g.
      SELECT FROM maintable,  
          [SELECT FROM othertable WHERE windspeed < 5] tmptab  
          WHERE any(time >= [SELECT starttime FROM tmptab]  
                 && time <= [SELECT endtime FROM tmptab])

    However, below an even nicer solution is given.

  2. The time range problem above can be solved elegantly by using a set as the result of the subquery. Instead of a table name, it is possible to give an expression in the GIVING clause (as mentioned in section 3.10). E.g.
      select from MY.MS where TIME in  
          [select FROM OTHERTABLE where WINDSPEED < 5  
               giving [TIME-INTERVAL/2 =:= TIME+INTERVAL/2]]

    The set expression in the GIVING clause is ï¬lled with the results from the subquery and used in the main query. So if the subquery results in 5 rows, the resulting set contains 5 intervals. Thereafter the resulting intervals are sorted and combined where possible. In this way the minimum number of intervals have to be examined by the main query.

  3. In Casacore the other table will often be the name of a subtable, which is stored in a table or column keyword of the main table. The standard keyword syntax can be used to indicate that the other table is the table in the given keyword. Note that for a table keyword the :: part has to be given, otherwise the name is treated as an ordinary table name. E.g.
      select from MY.MS where TIME in  
          [select TIME from ::WEATHER where WINDSPEED < 5]

    In this example the other table is a subtable of table my.ms. Its name is given by keyword WEATHER of my.ms.

  4. Often the result of a query on a subtable of a measurement set is used to select columns from the main table. However, several subtables do not have an explicit key, but use the row number as an implicit key. The function ROWID() can be used to return the row number as the subtable query result. E.g.
      select from MY.MS where DATA_DESC_ID in  
          [select from ::DATA_DESCRIPTION where  
             SPECTRAL_WINDOW_ID in [0,2,4] giving [ROWID()]]

    Note that the function ROWNUMBER cannot be used here, because it will give the row number in the selection and not (as ROWID does) the row number in the original table. Furthermore, ROWID gives a 0-relative row number which is needed to be able to use it as a selection criterium on the 0-relative values in the measurement set.

  5. Select if any channel has a UV distance < 100 wavelengths.
      select from MY.MS where any(sqrt(sumsqr(UVW[:2])) / c() *  
          [select CHAN_FREQ from ::SPECTRAL_WINDOW][DATA_DESC_ID,]  
             < 100)

    In a MeasurementSet the UVW coordinates are stored in meters, so they have to be multiplied with the frequency and divided by speed of light to get them in wavelengths.
    Because TaQL has no proper join operation, it is not possible to select directly on the DATA_DESC_ID. However, using a nested query and indexing the result with the DATA_DESC_ID has the same effect. It only requires that CHAN_FREQ has the same length in all rows in the subtable.
    Using the new derivedmscal functions, below a much nicer solution is given.

  6.   select from MY.MS where any(mscal.uvwwvls() < 100)

    It shows how the UVWWVLS function in derivedmscal can be used to obtain the UVW coordinates in wavelengths.

  7. Calculate the angular distance between the Mars and Jupiter as seen from the WSRT for the coming 30 days.
      calc angdist(meas.app(’mars’,    date()+[0:31], ’WSRT’),  
                   meas.app(’jupiter’, date()+[0:31], ’WSRT’))

5 Aggregation, GROUPBY, HAVING

Similar to SQL it is possible to do aggregation and grouping in TaQL and to do selection on the groups using the HAVING clause.

5.1 Aggregation and GROUPBY

One or more aggregated values can be calculated for a group deï¬ned by the GROUPBY clause. The aggregate functions described in section 4.10.13 can be used. For example:

  SELECT ANTENNA1, ANTENNA2, gcount(), sqrt(sumsqr(UVW[:2]))  
      FROM my.ms GROUPBY ANTENNA1,ANTENNA2

A group is formed for the unique values of the columns given in the GROUPBY clause. In the example above a group per baseline is formed. Usually an aggregate function is ued to calculate a value for the group. In the example above the aggregate function gcount() counts the number of rows per baseline.
Often only the GROUPBY columns and aggregated values are part of the SELECT clause, but the example shows that other values (here the baseline length) can also be selected. Non-aggregated values get the values in the last row of a group.

Usually aggregated values and GROUPBY are used jointly, but it is possible to leave out one of them. If GROUPBY is not given, the entire table is a single group. For example:

  SELECT gcount() from my.ms

does not have groups, thus shows the total number of rows in the MS.

  SELECT ANTENNA1,ANTENNA2 from my.ms GROUPBY ANTENNA1,ANTENNA2

does not use aggregate functions, but shows the unique baselines in the MS. Apart from the order, it has the same result as

  SELECT ANTENNA1,ANTENNA2 from my.ms ORDERBY UNIQUE ANTENNA1,ANTENNA2

but is somewhat faster.

In the examples above a sole aggregate function is used, but it is also possible to use it in an expression. Similarly, an expression can be used in the GROUPBY. For example:

  select ctod(gmean(TIME)), gcount() from ~/data/GER.MS  
    groupby round((TIME -  
      [select gmin(TIME) from ~/data/GER.MS][0])/INTERVAL/5)

groups the MS in chunks of 5 time slots. Note that the nested query gets the TIME of the ï¬rst time slot. The result is a set, hence the 0th element has to be taken.

Note that an aggregate function can only be used in the SELECT and HAVING clause, so TaQL will give an error message if used elsewhere.

5.2 HAVING

The HAVING clause can be used to select speciï¬c groups. For example:

  SELECT TIME, gmax(amplitude(DATA)) as MAXA from my.ms GROUPBY TIME  
      HAVING MAXA > 100  
  SELECT TIME, gmax(amplitude(DATA)) from my.ms GROUPBY TIME  
      HAVING gmax(amplitude(DATA)) > 100

groups by time, but only selects the groups for which the maximum amplitude of the DATA is more than 100. Both examples give the same result, but the ï¬rst one is more efficient. Not only it is less typing, but it is faster because it reuses the result column MAXA of the SELECT part.
Similar to WHERE, any expression can be used in HAVING, but the result has to be a bool scalar value.

As shown in the example, HAVING will normally use aggregate functions, but it is not strictly needed. However, selections without an aggregate function could as well be done in the WHERE clause.
Usually HAVING will be used in combination with GROUPBY, but it can be used without. It can also be used without an aggregate function in the SELECT. However, it is an error if both are omitted.

6 Some further remarks

6.1 Joining tables

As discussed in some previous sections it is possible to join tables on row number. Two examples show how to do it.

6.1.1 Join on row number
  SELECT FROM mytable t1,othertable t2  
    WHERE not all(t1.DATA ~= t2.DATA)

This command can be used to check if the data in mytable is about equal to the data in othertable. Both tables have to have the same number of rows.
The join is done on row number, thus the data in corresponding rows are compared.

6.1.2 Join using an indexed subquery
  SELECT [SELECT NAME FROM ::ANTENNA][ANTENNA1]  
         FROM ~/GER1.MS

This example shows how a subquery is used to join the main table of a MeasurementSet with its ANTENNA subtable. The subquery returns a list with the names of all antennae, which subsequently is indexed with the antenna number to get the antenna name for each row in the main table.
The join is done using the ANTENNA1 column which gives the row number in the subtable, thus the index in the subquery result.

6.1.3 Join using a subquery set
  SELECT FROM ~/GER1.MS WHERE ANTENNA1 IN  
         [SELECT ROWID() FROM ::ANTENNA WHERE NAME ~ p/CS*/]

This example shows another way to use a subquery for a join of the main table of a MeasurementSet with its ANTENNA subtable. It selects all baselines for which the ï¬rst station is a core station. The subquery returns a set containing the ids of the core stations, which is used to select the correct stations in the main table.

6.1.4 Join using derivedmscal

Several UDFs in the derivedmscal library make it possible to easily join a MeasuementSet or CASA Calibration Table with a subtable like ANTENNA or SPECTRAL_WINDOW. These functions know which columns to use making the join straightforward like in

  SELECT mscal.ant1name(), mscal.ant2name() from ~/GER1.MS

The library also contain the more general SUBCOL function making it possible to join any table with a subtable. For example:

  SELECT mscal.subcol(’NAMES’,’NAME’,NAMEID) from obs.parmdb

to get the parameter name for a LOFAR ParmDB table. A ParmDB table has a subtable NAMES containing the NAME and other info of a parameter. The column NAME_ID is used to reference that subtable.

6.2 Optimization

A lot of development work could be done to improve the query optimization. At this stage only a few simple optimizations are done.

  • Constant subexpressions are calculated only once. E.g.
    in COL*sin(180/pi()) the part sin(180/pi()) is evaluated once.
  • If a subquery generates intervals of reals or dates, overlapping intervals are combined and eliminated. E.g.
      select from GER.MS where TIME in [select from ::POINTING where  
       sumsqr(DIRECTION[1])>0 giving [TIME-INTERVAL/2=:=TIME+INTERVAL/2]]

    can generate many identical or overlapping intervals. They are sorted and combined where possible to make the set as small as possible.

  • If the righthand side of the IN operator is a single value, IN is turned into ==.
  • If the righthand side of the IN operator is a set of integer values with a min-max range of <=1024*1024, that set is turned into a boolean vector to get linear lookup time.

TaQL does not recognize common subexpressions nor does it attempt to optimize the query. It means that the user can optimize a query by specifying the expression carefully. When using operator ∣∣ or &&, attention should be paid to the contents of the left and right branches. Both operators evaluate the right branch only if needed, so if possible the left branch should be the shortest one, i.e., the fastest to evaluate.

The user should also use functions, operators, and subqueries in a careful way.

  • SQUARE(COL) is (much) faster than COL**2 or POW(COL,2), because SQUARE is faster. It is also faster than COL*COL, because it accesses column COL only once.
    Similarly SQRT(COL) is faster than COL**0.5 or POW(COL,0.5)
  • SQUARE(U) + SQUARE(V) < 1000**2 is considerably faster than
    SQRT(SQUARE(U) + SQUARE(V)) < 1000, because the SQRT function does not need to be evaluated for each row.
  • TIME IN [0 <:< 4] is faster than TIME >0 && TIME <4, because in the ï¬rst way the column is accessed only once.
  • Returning a column from a subquery can be done directly or as a set. E.g.
      SELECT FROM maintable WHERE time IN  
          [SELECT time FROM othertable WHERE windspeed < 5]

    could also be expressed as

      SELECT FROM maintable WHERE time IN  
          [SELECT FROM othertable WHERE windspeed < 5 GIVING [time]]

    The latter (as a set) is slower. So, if possible, the column should be returned directly. This is also easier to write.
    An even more important optimization for this query is writing it as:

      SELECT FROM maintable WHERE time IN  
          [SELECT DISTINCT time FROM othertable WHERE windspeed < 5]

    Using the DISTINCT qualiï¬er has the effect that duplicates are removed which often results in a much smaller set.

  • Testing if a subquery contains at least N elements can be done in two ways:
      count([select column from table where expression]) >= N  
    and  
      exists (select from table where expression limit N)

    The second form is by far the best, because in that case the subquery will stop the matching process as soon as N matching rows are found. The ï¬rst form will do the subquery for the entire table.
    Furthermore in the ï¬rst form a column has to be selected, which is not needed in the second form.

  • Sometimes operator IN and function ANY can be used to test if an element in an array matches a value. E.g.
      WHERE any(arraycolumn == value)  
    and  
      WHERE value IN arraycolumn

    give the same result. Operator IN is faster because it stops when ï¬nding a match. If using ANY all elements are compared ï¬rst and thereafter ANY tests the resulting bool array.

  • It was already shown in the section 4.8 that indexing arrays should be done with care.

7 Modifying a table

Usually TaQL will be used to get a subset from a table. However, as described in the ï¬rst sections, it can also be used to change the contents of a table using the UPDATE, INSERT, or DELETE command. Note that a table has to be writable, otherwise those commands exit with an error message.

7.1 UPDATE

  UPDATE table SET update_list [FROM table_list]  
                               [WHERE ...] [ORDERBY ...]  
                               [LIMIT ...] [OFFSET ...]

updates all or some rows in the ï¬rst table. More input tables can be given in the FROM clause and used in clauses like SET and WHERE. Unlike SQL it is possible to specify more tables in the UPDATE part which is the same as specifying them in the FROM clause. However, using the FROM clause makes it more clear that only the ï¬rst table is updated.
update_list is a comma-separated list of column=expression parts. Each part tells to update the given column using the expression. Both scalar and array columns are supported. E.g.

  UPDATE vla.ms SET ANTENNA1=ANTENNA1-1, ANTENNA2=ANTENNA2-1

to make the antenna numbers zero-based if accidently they were written one-based.

  UPDATE this.ms set DATA=t2.DATA, FLAG=t2.FLAG  
             FROM that.ms t2 where all(FLAG)  
  UPDATE this.ms, that.ms t2 set DATA=t2.DATA, FLAG=t2.FLAG  
                             where all(FLAG)

are equivalent. They copy the DATA and FLAG column of that.ms to this.ms for rows where all data in this.ms are flagged. Note the use of the shorthand (alias) t2.

If an array gets an array value, the shape of the array can be changed (provided it is allowed for that table column). Arrays can also be updated with a scalar value causing all elements in the array to be set to that scalar value.

  UPDATE vla.ms SET FLAG=F

It sets all elements of the arrays in column FLAG to False.

Type promotion and demotion will be done where possible. For example, an integer column can get the value of a double expression (the result will be truncated).
Unit conversion will be done as needed. Thus if a column and its expression have different units, the expression result is automatically converted to the column’s unit. Of course, the units must be of the same type to be able to convert the data.

Note that if multiple column=expression parts are given, the columns are changed in the order as speciï¬ed in the update-list. It means that if an updated column is used in an expression for a later column, the new value is used when evaluating the expression. e.g., in

  UPDATE vla.ms SET DATA=DATA+1, SUMD=sum(DATA)

the SUMD update uses the new DATA values.

Thus to swap the values of the ANTENNA1 and ANTENNA2 column, one can not do:

  UPDATE vla.ms SET ANTENNA1=ANTENNA2, ANTENNA2=ANTENNA1

To solve this problem a temporary table (in this case in memory) can be used to save the value of e.g., ANTENNA1:

  UPDATE my.ms  
      set ANTENNA1 = ANTENNA2, ANTENNA2 = orig.ANTENNA1  
      FROM [select ANTENNA1 from my.ms giving as memory] orig

7.1.1 Partial Array Update

It is possible to update part of an array using array indexing and slicing. E.g.,

  UPDATE vla.ms SET FLAG[1,1]=T  
  UPDATE vla.ms SET FLAG[1,]=T

The ï¬rst example sets only a single array element, while the second one sets an entire row in the array. Similar to numpy it is also possible to use a mask like

  UPDATE vla.ms SET FLAG[isnan(DATA)]=T

which sets the flag for the DATA values being a NaN. The data and mask must have the same shape. Note this is easier to write than the similar command

  UPDATE vla.ms SET FLAG = iif(isnan(DATA), T, FLAG)

Masking and slicing can be combined making it possible to use masking on a part of an array. If the mask is given ï¬rst, the slice is taken from both the data and mask. If the slice is given ï¬rst, it is only applied to the data; the mask should have the same shape as the slice. For example:

  UPDATE vla.ms SET FLAG[isnan(DATA)][,0]=T  
  UPDATE vla.ms SET FLAG[,0][isnan(DATA[,0])]=T

Both commands set the flag for NaN data in the XX polarization. The ï¬rst one is somewhat easier to write, but processes the entire DATA and FLAG before taking the slice. The second one only reads and processes the required parts of DATA and FLAG, thus is more efficient.

7.1.2 Update columns from a masked array

If a column is updated with the value of a masked array, only the array part of the masked array is used. However, it is also possible to jointly update the data column and mask column from a masked array by combining them in parentheses like:

  UPDATE vla.ms SET (DATA,FLAG)=maskedarray

It writes the data part into DATA and the mask into FLAG. As above it is possible to use a slice or mask operator on the combination like:

  UPDATE vla.ms SET (DATA,FLAG)[,0]=maskedarray  
  UPDATE vla.ms SET (DATA,FLAG)[isnan(DATA)]=maskedarray

The slice or mask is applied to both columns.

7.2 INSERT

The INSERT command adds rows to the table. It can take three forms:

  INSERT INTO table_list SET column=expr, column=expr, ...  
  INSERT INTO table_list [(column_list)] VALUES (exprlist),(exprlist), ...  
  INSERT INTO table_list [(column_list)] SELECT_command

The ï¬rst and second form are basically equivalent, but differ in syntax. The ï¬rst form has the same syntax as the UPDATE command, while the second form is the SQL syntax making it possible to leave out the column names (see below). In both forms it is possible to jointly specify data column and mask column if the value is a masked array. This is done by combining them in parentheses like (DATA,FLAG) as described in the previous subsection for the UPDATE command.

The ï¬rst form adds one row to the table and puts the values given in the expressions into the columns.
For example:

  INSERT INTO my.ms SET ANTENNA1=0, ANTENNA2=1

adds one row, puts 0 in ANTENNA1 and 1 in ANTENNA2.

The second form can add multiple rows to the table. It puts the values given in the expression lists into the columns given in the column list. If the column list is not given, it defaults to all stored columns in the table in the order as they appear in the table description. Multiple expression lists can be given; each list results in the addition of a row. Each expression in the expression list can be as complex as needed; for example, a subquery can also be given. Note that a subquery is evaluated before the new row is added, so the new row is not taken into account if the subquery is done on the table being modiï¬ed.
It should be clear that the number of columns has to match the number of expressions.
Note that row cells not mentioned in the column list, are not written, thus may contain rubbish in the new rows.
The data types and units of expressions and columns have to conform in the same way as for the UPDATE command; values have to be convertible to the column data type and unit.
For example:

  INSERT INTO my.ms (ANTENNA1,ANTENNA2) VALUES (0,1),(2,3)

adds two rows, putting 0 and 2 in ANTENNA1 and 1 and 3 in ANTENNA2.

The LIMIT clause can be used to add multiple rows while giving fewer expressions. LIMIT can be given at the beginning or the end of the command. For example:

  INSERT INTO my.ms (COL1) VALUES (rowid()) LIMIT 100  
  INSERT LIMIT 5 INTO my.ms (COL1,COL2) VALUES (0,0),(1,1)

The ï¬rst example will add 100 rows where the value in each row is the row number. The second example shows that multiple expression lists can be given. It will iterate through them while adding rows. Thus COL1 and COL2 will have the values 0, 1, 0, 1, and 0 in the new rows.

The third form evaluates the SELECT command and copies the rows found in the selection to the table being modiï¬ed (which is given in the INTO part). The columns used in the modiï¬ed table are deï¬ned in the column list. As above, they default to all stored columns. The columns used in the selection have to be deï¬ned in the column-list part of the SELECT command. They also default to all stored columns.
For example:

  INSERT INTO my.ms select FROM my.ms

appends all rows and columns of my.ms to itself. Please note that only the original number of rows is copied.

  INSERT INTO my.ms (ANTENNA1,ANTENNA2) select ANTENNA2,ANTENNA1  
   FROM other.ms WHERE ANTENNA1>0

copies rows from other.ms where ANTENNA1 >0. It swaps the values of ANTENNA1 and ANTENNA2. All other columns are not written, thus may contain rubbish.

7.3 DELETE

  DELETE FROM table_list  
    [WHERE ...] [ORDERBY ...] [LIMIT ...] [OFFSET ...]

deletes some or all rows from a table.

  DELETE FROM my.ms WHERE ANTENNA1>13 OR ANTENNA2>13

deletes the rows matching the WHERE expression.
If no selection is done, all rows will be deleted.
It is possible to specify more than one table in the FROM clause to be able to use, for example, keywords from other tables. Rows will be deleted from the ï¬rst table mentioned in the FROM part.

8 Creating a new table

TaQL can be used to create a new table. The data managers to be used can be given in full detail. The syntax is:

  CREATE TABLE tablename AS options colspecs LIMIT nrows DMINFO datamanagers

The command consists of 4 parts, all of them optional.

  • The table name and options can be given in the same way as in the GIVING clause.
  • The columns are deï¬ned in the colspecs part. If not given, a table without any column is created. Below column speciï¬cation is described in more detail.
  • An expression giving the number of rows can be speciï¬ed in the LIMIT part. If not given, it defaults to 0.
  • For expert users data managers can be deï¬ned in the optional DMINFO part described further down.

The CREATE TABLE command can be used in a nested query making it possible to ï¬ll it immediately. For example:

  update [create table a.tab col1 int limit 10] set col1=rowid()

creates a table with one column and ten rows. The column is ï¬lled with the row number. Note that the following command would do the same.

  select rowid() as col1 int limit 10 giving a.tab

8.1 Column speciï¬cation

The colspecs part deï¬nes the column names, their data types, and optional shapes and units. It can optionally be enclosed in square brackets or parentheses (for SQL compatibility). It is a comma separated list of column speciï¬cations. Each speciï¬cation looks like:

  columnname datatype [NDIM=n, SHAPE=[d1,d2,...], UNIT=’s’,  
                       DMTYPE=’s’, DMGROUP=’s’, COMMENT=’s’]

The possible data type strings are given in section 4.1. The part enclosed in square brackets is optional. Zero or more of these keywords can be used. It makes it possible to deï¬ne array columns and/or default data manager to be used. The square brackets are optional if only one such keyword is used.

  • NDIM=n deï¬nes if the column contains scalars or arrays.
    A negative value means a scalar, which is the default (unless shape is also given). A value 0 means an array of any dimensionality. A positive value means an array with the given dimensionality.
  • SHAPE=[d1,d2,...] makes it possible to deï¬ne the exact array shape.
    If given and if NDIM is positive, they should be consistent.
  • UNIT=’s’ deï¬nes the unit to be used for the column.
    It can be any valid unit (simple or compound). It is a string, thus must always be enclosed in quotes.
  • COMMENT deï¬nes comments for the column.
    It has a string value, thus quotes have to be used.
  • DMTYPE, DMGROUP are rather speciï¬c and are for the expert user.
    They have a string value, thus quotes have to be used.

8.2 Data manager speciï¬cation

The datamanagers part makes it possible for the expert user to deï¬ne the data managers to be used by columns. It is a comma separated list of data manager speciï¬cations looking like the output of the table.getdminfo command in Python. Each speciï¬cation has to be enclosed in square brackets. For example:

  dminfo [NAME="ISM1",TYPE="IncrementalStMan",COLUMNS=["col1"]],  
         [NAME="SSM1",TYPE="StandardStMan",  
          SPEC=[BUCKETSIZE=1000],COLUMNS=["col2","col3"]]

The case of the keyword names used (e.g., NAME) is important. They have to be given in uppercase. The following keywords can be given:
NAME deï¬nes the unique name of the data manager.
TYPE deï¬nes the type of data manager.
SPEC is a list of keywords giving the characteristics of the data manager. This is highly data manager type speciï¬c. If shapes have to be given here, they always have to be in Casacore format, thus in Fortran order. TaQL has no knowledge about these internals.
COLUMNS is a list of column names deï¬ning all columns that have to be bound to the data manager.

9 Modifying the table structure

TaQL can be used to modify the table structure, i.e., to add, rename, and remove columns and keywords. It is also possible to add rows. The syntax is:

  ALTER TABLE tablename FROM table_list subcommand_list

It changes the table with the given name. The tables given in the optional FROM clause can be used in expressions deï¬ning keyword values. Any number of subcommands can be given, separated by whitespace and/or comma. The following subcommands can be given. They are explained in the next subsections.

  ADD COLUMN colspecs DMINFO datamanagers  
  RENAME COLUMN old TO new, old TO new, ...  
  DELETE COLUMN column_list  
  SET KEYWORD name=value AS dtype, ...  
  COPY KEYWORD name=name AS dtype, ...  
  RENAME KEYWORD old TO new, old TO new  
  DELETE KEYWORD keyword_list  
  ADD ROW nrows

The nouns COLUMN and KEYWORD can also be given in the plural form. The whitespace between verb and noun is optional. For SQL-compatibility DROP can be used instead of DELETE.
For example:

  ALTER TABLE my.tab RENAME COLUMN Col1 to Col1A, ADDCOLUMNS Col1 I4

renames column Col1 to Col1A and adds a new column Col1 with data type I4.

Note that TaQL has no way of showing keywords that have a record value. The program showtable can be used for that purpose.

9.1 ADD COLUMN

  ADD COLUMN colspec DMINFO datamanagers

adds one or more columns to the table. The speciï¬cation of the columns and the optional data managers is the same as used in the CREATE TABLE command. Thus for each column a data type, dimensionality or shape, and unit can be given. The data manager(s) for the new columns can be speciï¬ed in the DMINFO part. If not given, StandardStMan will be used. For example:

  ADD COLUMN NCol1 R4, NCol2 R8 [UNIT="m", NDIM=3]

adds two columns, a 4-byte floating point scalar column and an 8-byte floating point 3-dim array column. They will be stored with StandardStMan.

9.2 RENAME COLUMN

  RENAME COLUMN old1 TO new1, old2 TO new2, etc.

renames one or more columns in a table. For example:

  RENAME COLUMN NAME to NAME_SAV, ADDR to ADDR_SAV

9.3 DELETE COLUMN

  DELETE COLUMN col1, col2, etc.

removes one or more columns. Note that if multiple columns are combined in a TiledStMan, they have to be removed at the same time. Thus in that case

  DELETE COLUMN col1, col2  
  DELETE COLUMN col1, DELETE COLUMN col2

are not the same, because the second example might fail.

9.4 SET KEYWORD

  SET KEYWORD key1=value1 AS dtype, etc.

adds a keyword with the given value or replaces the value if the keyword already exists. The value of a keyword can be a scalar, array, or arbitrarily deeply nested record. See section 4.5 how to specify a keyword name in a column or nested record. The AS dtype part can be used to explicitly set the data type of a new keyword. For an existing keyword, the data type of the new value has to match the data type of the current value.

The value can be an expression, possibly using values from another table given in the FROM clause. It has to be a constant expression, thus cannot depend on column values. Of course, column values can be used when aggregated to a single value. If no data type is given, the data type of the expression result is used. If given, upward and downward coercion is possible (e.g., integer to float and also float to integer). For example:

  SET KEYWORD key1=4  
  SET KEYWORD ::key1=4+5 AS U4  
  SET KEYWORD key1 = otherkey as I4  
  SET KEYWORD col::ckey.subrec.fld1 = [4,5,6.]  
  SET KEYWORD col::ckey=[=], col::ckey.subrec=[=]  
  SET KEWYORD key=[] AS I4

The 1st example sets table keyword key1 to 4. Its data type is not given, thus is the expression’s data type, in this case I8.
The 2nd example sets key1 to 9, but as an unsigned 4 byte integer. Note that the :: part is redundant.
The 3rd example copies the value of keyword otherkey while converting its data type to I4. Note that if no data type is given, the data type of otherkey is NOT preserved, because it is seen as a TaQL expression which has data type I8 (or R8).
The 4th example sets the ckey.subrec.fld1 in column col to the given vector. It is a nested structure, thus ï¬eld fld1 in ï¬eld subrec of column keyword ckey will be set. Its data type will be R8.
Note that the command in the 4th example does not create the higher level records. If not existing yet, the 5th example can be used to create them, where [=] denotes an empty record (it is the old Glish syntax for an empty struct).
The last example shows how to create a key with an empty integer vector as value. In such a case the data type must be given, because it cannot be derived from the value.

Setting a keyword to the value of another keyword is easily possible. For instance:

  SET KEYWORD key2 = otherkey

However, it has two problems.
1) As explained above the data type might not be preserved.
2) Keywords having a record value cannot be copied this way, because TaQL expressions do not support record values.

9.5 COPY KEYWORD

  COPY KEYWORD key = otherkey AS dtype, etc.

copies the value of keyword otherkey to key. It can be used for any keyword value, thus also for records. The optional AS dtype part can be used to change the data type.

9.6 RENAME KEYWORD

  RENAME KEYWORD old1 TO new1, old2 TO new2, etc.

renames one or more table or column keywords. If the old keyword is a ï¬eld in a column or a nested record, the new name should only contain the new ï¬eld name, not the full keyword path. For example:

  RENAME KEYWORD NAME to NAME_SAV, Col1::CNAME to CNAME_SAV  
  RENAME KEYWORD KEYS.SET.NAME to NAME_SAV

The ï¬rst example renames the table keyword NAME and the keyword CNAME of column Col1.
The second example renames a ï¬eld in the nested records of table keyword KEYS.

9.7 DELETE KEYWORD

  DELETE KEYWORD key1, key2, ...

removes one or more table or column keywords.

9.8 ADD ROW

adds the given number of rows to the table.

  ADD ROW nrows

where nrows can be any expression. For example,

 ALTER TABLE mytab ADD ROW [SELECT GCOUNT() from othertab]

makes mytab the same size as othertab (assuming it was empty).

10 Counting in a table

Before TaQL had the GROUPBY command, the COUNT command could be used instead of the gcount aggregate function to count the number of occurrences in a table.
For backward compatibility this command can still be used, but its usage is discouraged, also because usually GROUPBY is faster.

The exact syntax is:

  COUNT column-list FROM table-list [WHERE expression]

It counts the number of rows for each unique tuple in the column list of the table (after the possible WHERE selection is done). For example:

  COUNT TIME FROM my.ms

counts the number of rows per timestamp.

  COUNT ANTENNA1,ANTENNA2 FROM my.ms

counts the number of rows per baseline.

As in the other TaQL commands a column in the column list can be any expression, but that will be slower than straight columns.

11 Calculations on a table

TaQL can be used to get derived values from a table by means of an expression. The expression can result in any data type and value type. For example, if the expression uses an array column, the result might be a vector of arrays (an array for each row). If the expression uses a scalar column, the result might be a vector of scalars or even a single scalar if a reduce function like SUM is used.

The CALC command was developed before the GROUPBY was available and before SELECT could be used without the FROM part. Currently, SELECT is more powerful than the CALC command. For example, multiple expressions can be given in a SELECT command. However, especially in Python sessions CALC has the advantage that it returns the results as a numpy-array or a list instead of a Casacore table.

The exact syntax is:

  CALC expression [FROM table_list]

The part in square brackets can be omitted if no column is (directly) used in the expression. The examples will make clear what that means.
The following syntax is still available for backward compatibility:

  CALC FROM table_list CALC expression

  CALC 1in cm

is a simple expression not using a table. It shows how the CALC command can be used as a desk calculator to convert 1 inch to cm.

  CALC mean(column1+column2) FROM mytable

gives a vector of scalars containing the mean per row.

  CALC sum([SELECT FROM mytable GIVING [mean(column1+column2)]])

gives a single scalar giving the sum of the means in each row. Note that in this command the CALC command does not need the FROM clause, because it does not use a column itself. Columns are only used in the nested query which has a FROM clause itself.

12 Examples

12.1 Selection examples

Some examples are given starting with simple ones.

12.1.1 Reference table results

The result of the following queries is a reference table, because no expressions have been given in the column-list. This will be the most common case when using TaQL.

SELECT FROM some.ms WHERE ANTENNA1 != ANTENNA2
selects the cross-correlations in a MeasurementSet.
SELECT NAME FROM some.ms::ANTENNA
selects the NAME of all antennae in a MeasurementSet.
SELECT unique ANTENNA1,ANTENNA2 FROM some.ms
gives the baselines used in a MeasurementSet.
SELECT ANTENNA1,ANTENNA2 FROM some.ms GROUPBY ANTENNA1,ANTENNA2
does the same using the GROUPBY clause.
SELECT FROM mytable ORDERBY column0 DESC limit 10
selects the 10 highest values of column0.
SELECT FROM some.MS WHERE near(MJD(1999/03/30/17:27:15), TIME)
selects the rows with the given time from a MeasurementSet.
Note that the TIME is stored in seconds, but will automatically be converted to days.
SELECT FROM some.MS where TIME in
     [{MJD(1999/03/30/17:27:15),MJD(1999/03/30/17:29:15)}]
selects the rows in the given closed time interval.
SELECT FROM some.MS where TIME in
     [MJD(1999/03/30/17:27:15),MJD(1999/03/30/17:29:15)]
selects the rows having one of the given times.
Note the difference with the previous example where an interval was given. Here a set of two individual time values is given.
SELECT NAME FROM some.ms::ANTENNA WHERE NAME ! p/[CR]S*/
selects the names of the international LOFAR stations (not core or remote).
SELECT FROM some.ms WHERE ntrue(FLAG) >= 3
selects rows where at least 3 visibilities are flagged.
SELECT FROM book.table WHERE nelements(author) > 1
selects books with more than 1 author.
SELECT FROM some.ms WHERE any(ANTENNA1==[0,0,1] && ANTENNA2==[1,3,2])
selects the antenna pairs (baselines) 0-1, 0-3, and 1-2.
It requires some explanation. The two comparisons result in boolean vectors (with 3 elements). It matching elements are both true, the baseline in the table row matches. Thus the vectors are and-ed to see if any two matching elements are true.
SELECT FROM some.ms WHERE ANTENNA1 in [0,0,1] && ANTENNA2 in [1,3,2])
looks the same as above, but will select all baselines between the two sets, thus also 1-1, 1-3, and 0-2.
SELECT FROM some.ms t1, that.ms t2 WHERE !all(near(t1.DATA, t2.DATA, 1e-5))
selects all rows where the DATA columns in both tables are not equal (with some tolerance). Note the use of shorthands t1 and t2.
SELECT FROM mytable WHERE cos(0d1m) <=
     sin(52deg) * sin(DEC) + cos(52deg) * cos(DEC) * cos(3h30m - RA)
selects observations with an direction (in say J2000) inside a cone with a radius of 1 arcmin around (3h30m, 52deg). To ï¬nd them the condition DISTANCE <=RADIUS must be fulï¬lled, which is equivalent to COS(RADIUS) <=COS(DISTANCE).
SELECT FROM mytable WHERE [RA,DEC] INCONE [3h30m, 52deg, 0d1m]
does the same as above in an easier (and faster) way.
SELECT FROM mytable WHERE angdist([RA,DEC], [3h30m, 52deg]) <= 0d1m]
is another way to do the above.
SELECT FROM mytable WHERE object == pattern("3C*") &&
     [RA,DEC] INCONE [3h30m, 52deg, 0d1m]
ï¬nds all 3C objects inside that cone.
SELECT ANTENNA1,ANTENNA2,sqrt(sumsqr(UVW[:2]))
     FROM some.ms GROUPBY ANTENNA1,ANTENNA2
ï¬nds the 10 longest baselines. It groups by ANTENNA1 and ANTENNA2 to get the unique baselines. UVW[:2] denotes the U and V coordinate giving the baseline length.
select from MY.MS where DATA_DESC_ID in [select from ::DATA_DESCRIPTION where
     SPECTRAL_WINDOW_ID in [0,2,4] giving [ROWID()]]
ï¬nds all rows in a measurement set matching the given spectral windows. It uses a nested query to ï¬nd the DATA_DESC_ID for each spectral window.
select from MY.MS where TIME in [select from ::SOURCE where REST_FREQUENCY < 180MHz
     giving [TIME-INTERVAL/2 =:= TIME+INTERVAL/2]]
ï¬nds all rows in a measurement set observing sources with a rest frequency less than 180 Mhz.
select from VLA.MS,
     [select from VLA.MS where sumsqr(UVW[:2]) < 625] as TIMESEL
     where TIME in [select distinct TIME from TIMESEL]
     && any([ANTENNA1,ANTENNA2] in [select from TIMESEL giving
     [iif(UVW[2] < 0, ANTENNA1, ANTENNA2)]])
selects rows where an antenna (VLA has 25 m diameter) is shadowed.
The query in the FROM command ï¬nds all rows where an antenna is shadowed (i.e., its UV-distance less than 25 meters) and creates a temporary table. This selection (named TIMESEL) is done ï¬rst otherwise two 2 equal selections are needed in the main WHERE command. The last line determines which antenna is shadowed (based on the W coordinate). The two lines above selects the times and baselines where an antenna is shadowed.
select from MS
     where DATA_DESC_ID in [select from ::DATA_DESCRIPTION
     where SPECTRAL_WINDOW_ID in [select from ::SPECTRAL_WINDOW
     where NET_SIDEBAND==1 giving [ROWID()]] giving [ROWID()]]
ï¬nds all rows in the MeasurementSet with the given NET_SIDEBAND.
The MeasurementSet uses a table to map spectral-window-id to data-desc-id. Hence two nested subqueries are needed.
select findcone(REFERENCE_DIR[0,],
     [16h34m33.805,62d45m36.83, 12h29m06.7,2d3m9], 1arcsec)
     from MS/FIELD
compares the direction given in the ï¬rst argument with the directions given in the second function argument using the search radius given in the third argument. It returns the index of the ï¬rst matching cone (thus 0 or 1). If no cone matches, it returns -1.
It can be used in the following example to ï¬nd the name of the source matching a direction.
select [’unknown’,’3C343’,’3C273’][1+findcone(...)] from MS/FIELD where ... is the ï¬ndcone argument list given in the previous example. 1 is added to cope with the case that no cone matches.

12.1.2 Plain table results

The following examples result in a plain table, thus in a deep copy of the query results, because the column-list contains an expression or a data type.

SELECT column0+column1 FROM mytable
creates a table of 1 column with name Col_1. Its data type is on the expression data type.
SELECT column0+column1 Res I4 FROM mytable
creates a table of 1 column with name Res. Its data type is a 4 byte signed integer.
SELECT colx colx R4 FROM mytable
creates a table of 1 column with name colx. The sole purpose of this selection is to convert the data type of the column.
SELECT means(DATA,0) AS DATA_MEAN C4 FROM my.ms
creates a table of 1 column with name DATA_MEAN. Column DATA in a Casacore MeasurementSet is a 2-dimensional array with axes polarization and frequency. This command calculates and stores the mean in each polarization. If no data type was given, the means would have been stored as double precision complex (which is the expression data type).
Note that this command is valid when using python style; in glish style MEANS(DATA,2) should be used.

12.2 Modiï¬cation examples

update MY.MS set VIDEO_POINT=MEANS(DATA,2) where isdefined(DATA)
sets the VIDEO_POINT of each correlation to the mean of the DATA for that correlation. Note that the 2 indicates averaging over the second axis, thus the frequency axis.
update MY.MS set FLAG_ROW=T where isdefined(FLAG) && all(FLAG)
sets FLAG_ROW in the rows where the entire FLAG array is set.
delete from MY.MS where FLAG_ROW
deletes all flagged rows.
insert into MY.MS select from OTHER.MS where !FLAG_ROW
copies all unflagged rows from OTHER.MS to MY.MS.
insert into MY.MS/DATA_DESCRIPTION
     (SPECTRAL_WINDOW_ID,POLARIZATION_ID,FLAG_ROW)
     values (1,0,F)
adds a row to the DATA_DESCRIPTION subtable and initializes it.

12.2.1 Applying running median to an image

The following command shows how a running median can be applied to an Casacore image.

  update my.imgd set map = map - runningmedian(map,25,25)’)

The running medians are subtracted from the data in the copy. It uses a half window size of 25x25, thus the full window is 51x51.
When doing this, one should take care that in case of a spectral line cube the image is not too large, otherwise it won’t ï¬t in memory. If too large, it should be done in chunks like:

  update my.imgd set map[,,sc:ec,] =  
             map[,,sc:ec,] - runningmedian(map[,,sc:ec,],25,25)’)

where sc and ec are the start and end frequency channel. In this example it is assumed that the axes of the image are RA, DEC, freq, Stokes.
Note that the image is updated, so it should have been copied before if the original data needs to be kept.

12.3 Table creation examples

create table mytab (col1 I4, col2 I4, col3 R8)
creates table mytab of 3 scalar columns.
create table mytab
creates an empty table.
create table mytab colarr R4 ndim=0
creates a table of 1 array column with arbitrary dimensionality.
create table mytab colarr R4 [shape=[4,128], dmtype=’TiledColumnStMan’]
creates a table of 1 array column with the given shape. The column is stored with the TiledColumnStMan storage manager using its default settings.
create table mytab colarr R4 shape=[4,128]
     dminfo [TYPE=’TiledColumnStMan’, NAME=’TCSM’,
     SPEC=[DEFAULTTILESHAPE=[4,32,64]], COLUMNS=[’colarr’]]
creates a table of 1 array column with the given shape. The column is stored with the TiledColumnStMan storage manager using the given settings.

12.4 Calculation examples

calc 1+2
uses TaQL as a desktop calculator.
calc 7-Apr-2007 - 20-Nov-1979
calculates the number of days between these dates.
calc sum([select from MY.MS giving [ntrue(FLAG)]])
determines the total number of flags set in the measurement set.
calc mean(abs(DATA))
from [select from MY.MS where ANTENNA1==0]

calculates for each row the mean of the data for the selected subset of the measurement set.

calc mean([select from MY.MS where ANTENNA1==0
     giving [mean(abs(DATA))]])

looks like the previous example. It, however, calculates the mean of the mean of the data in each row for the selected subset of the measurement set.

calc max([select from MY.MS where isdefined(DATA)
     giving [max(abs(VIDEO_POINT-MEANS(DATA,0)))]])

shows the maximum absolute difference between VIDEO_POINT of each correlation and the mean of the DATA for that correlation. Note that the 2 indicates averaging over the ï¬rst axis, thus the frequency axis.

12.5 Aggregation/groupby examples

select gcount(*) from my.ms
counts the number of rows in the table.
select TIME, gcount(*) from my.ms groupby TIME
counts the number of rows (usually number of baselines) per time slot.
select ANTENNA1,ANTENNA2,gfirst(TIME),glast(TIME),gcount()
     from my.ms groupby ANTENNA1,ANTENNA2
counts the number of rows (usually number of time slots) and shows the ï¬rst and last time per baseline.
select gmean(DATA) from my.ms
     groupby int((TIME - [select TIME from my.ms limit1][0]) / INTERVAL / 10))
calculates the average of DATA for every 10 time slots. Note it also averages in frequency and polarization. The following example shows how to average each frequency channel and polarization.
select boxedmean(gaggr(DATA), 10, 4) from my.ms
     groupby int((TIME - [select TIME from my.ms limit1][0]) / INTERVAL / 10))
calculates the average of DATA per polarization for every 10 time slots and 4 frequency channels. Note it it ï¬rst combines the data of each 10 time slots in a single array, after which the boxedmean function is used to average every [10,4,1] box.

12.5.1 Obtaining the flux density from visibility data

The Miriad program uvflux estimates the source I flux density and its standard deviation at the phase center without having to make an image. A single, not too complicated TaQL command (courtesy Dijkema, Heald) provides the same functionality on a MeasurementSet. For LOFAR it is best to use baselines with a length between 5 and 10 km. The command shows various aspects of TaQL that are explained below. The numbers at the beginning of the lines point to the text following the example.

4.    select gstddev(SUMMED) as STDVALS,  
4.           gmean(SUMMED) as MEANVALS,  
4.           gcount(SUMMED) as NVALS  
3.    from (select gmean(  
1.                  sum(iif(FLAG[,0:4:3], 0, abs(DATA[,0:4:3])))  
1.                   / nfalse(FLAG[,::3])  
3.                 ) as SUMMED  
            from ~/data/GER.MS  
2.          where mscal.baseline(’5km~10km) && !all(FLAG)  
3.          groupby TIME)

A subquery is used to get the average flux (I = 0.5*(XX+YY)) per time slot.

  1. For each baseline it gets the mean of the channels. Note that it uses sum/n to ignore flagged visibilities. The iif function tells to use 0 for them. Also note that XX is the 1st and YY the 4th polarisation, hence [0:4:3] (or [::3]) indexes these polarisations. Once masked arrays are supported by TaQL, it could be written as: mean(DATA[,::3][FLAG[,::3]])
  2. It only uses the baselines with lengths between 5 and 10 km where not all visibilities are flagged. Note that a mscal user deï¬ned function is used for the baseline selection as described in section 4.10.17.
  3. Thereafter the average flux per time slot is determined in the subquery using the gmean aggregation and GROUPBY functionality. The result is an intermediate table with one column called SUMMED and a row per time slot.
  4. Finally, the outer query uses aggregate functions to calculate the overall mean, standard deviation, and number of time slots from the result of the subquery. The ï¬nal result is a table with 1 row and 3 columns.

12.5.2 Number of fully flagged baselines per antenna

The example below counts per antenna the number of fully flagged baselines, excluding the autocorrelations. It uses grouping and aggregate functions twice; ï¬rst per baseline, thereafter per antenna. It also uses the concatenation and backreferencing features. It also shows the results when using the time keyword, which shows that the processing time is dominated by the ï¬rst query.

time select gsum(t1.cnt), t1.ANTENNA,  
       (select NAME from ~/data/3C343.MS::ANTENNA)[t1.ANTENNA] as NAME  
  from (select gcount() as cnt, ANTENNA1 as ANTENNA, ANTENNA2  
          from ~/data/3C343.MS where all(FLAG) and ANTENNA1!=ANTENNA2  
          groupby ANTENNA1,ANTENNA2) t0,  
  [t0,  
   (select cnt, ANTENNA2 as ANTENNA, 0 as ANTENNA2 from t0),  
   (select 0 as cnt, rowid() as ANTENNA, 0 as ANTENNA2  
           from ~/data/3C343.MS::ANTENNA)] t1  
  groupby t1.ANTENNA orderby t1.ANTENNA  
 
  From query          0.8 real        0.58 user        0.08 system  
  From query            0 real           0 user           0 system  
  From query            0 real           0 user           0 system  
  Subquery              0 real           0 user           0 system  
  Groupby               0 real           0 user           0 system  
  Orderby               0 real           0 user           0 system  
  Projection            0 real           0 user           0 system  
 Total time          0.83 real         0.6 user        0.08 system

  1. The ï¬rst inner select counts the number of fully flagged baselines per baseline and stores the result with the antennas making up a baseline in a temporary table with shorthand t0.. In this way the expensive counting part needs to be executed only once.
  2. This table has to be summed for both antennas of the baselines, which is done in the second part creating a concatenated table with shorthand t1. It backreferences the ï¬rst table t0 twice. First to use it directly to count for ANTENNA1, thereafter to count for ANTENNA2 by doing a select to make the ANTENNA2 the ANTENNA column.
  3. The table does not contain the antennas having no fully flagged baselines. Therefore the third part of the concatenation copies the ANTENNA table to insert zero counts for all antennas.
  4. Finally the outer select (in the ï¬rst line) sums the values in the concatenated table per antenna. It also retrieves the name of the antenna by indexing in the selection of all antenna names.

13 Interface to TaQL

User and a programmer interfaces to TaQL are available. The program taql and some Python and Glish functions form the user interface, while C++ classes and functions form the programmer interface.

13.1 Python interface python-casacore

The main TaQL interface in Python is formed by the query function in module table. The function can be used to compose and execute a TaQL command using the various (optional) arguments given to the query function. E.g.

   import casacore.tables as pt  
   tab = pt.table(’mytable’)  
   seltab1 = tab.query (’column1 > 0’)  
   seltab2 = seltab1.query (query=’column2>5’,  
                            sortlist=’time’,  
                            columns=’column1,column2’,  
                            name=’result.tab’)

The ï¬rst command opens the table mytable. The second command does a simple query resulting in a temporary table. That temporary table is used in the next command resulting in a persistent table. The latter function call is transformed to the TaQL command:

  SELECT column1,column2 FROM \$1 WHERE column2>5  
  ORDERBY time GIVING result.tab

During execution $1 is replaced by table seltab1.
Note that the name argument generates the GIVING part to make the result persistent.

The functions sort and select exist as convenience functions for a query consisting of a sort or column selection only. Both functions have an optional second name parameter to make the result persistent.

   t1 = tab.sort (’time’)  
   t1 = tab.select (’column1,column2’)

The calc function can be used to execute a TaQL calc command on the current table. The result can be kept in a variable. For example, the following returns a vector containing the median of the DATA column in each table row:

  med = t.calc (’median(DATA)’)

It is possible to embed Python variables and expressions in a TaQL command using the syntax $variable and $(expression). A variable can be a standard numeric or string scalar or vector. It can also be a table tool. An expression has to result in a numeric or string scalar or vector. E.g

  from casacore.tables import *  
  tab = table(’mytable’)  
  coldata = tab.getcol (’col’);  
  colmean = sum(coldata) / len(coldata);  
  seltab1 = tab.query (’col > $colmean’)  
  seltab2 = tab.query (’col > $(sum(coldata)/len(coldata))’)  
  seltab3 = tab.query (’col > mean([SELECT col from $tab])’)

These three queries give the same result.
The substitution mechanism is described in more detail in pyrap.util.

The most generic function that can be used is taql (or its synonym tablecommand). The full TaQL command has to be given to that command. The result is a table object. E.g.

  import pyrap.tables as pt  
  t = pt.taql(’select from GER.MS where ANTENNA1==1’);

By default, these commands will use the Python style for a TaQL statement. The style argument can be used to choose another style.

13.2 Interface to Glish

The Glish interface is formed by script table.g. By default, it will use the Glish style for a TaQL statement. For example:

  include ’table.g’  
  tab := table(’mytable’)  
  seltab1 := tab.query (’column1 > 0’)  
  seltab2 := seltab1.query (query=’column2>5’,  
                            sortlist=’time’,  
                            columns=’column1,column2’,  
                            name=’result.tab’)  
  t := tablecommand(’select from GER.MS where ANTENNA1==1’,  
                    style=’’);    # use default (glish) style  
  med := t.calc (’median(DATA)’)

13.3 Program taql

The program taql makes it possible to execute TaQL commands from the shell. Commands can be given in different ways:

  • The TaQL command can be given directly as command line arguments to the taql program. The arguments will be combined to a single command (separated by a space). Note that using multiple arguments instead of a single (quoted) argument makes it easier to use tab-completion for the table name. It will execute the command, show the result, and exit.
  • Using the -f option, the name of a ï¬le containing one or more TaQL commands can be given. The commands can be split over multiple lines, where a # can be used for comments. A semicolon has to be used to separate commands. The special commands listed below for the interactive case, can also be given.
  • The program is run interactively if command nor -f is given. It will run until the user stops via the command exit, quit, or q or by giving Ctrl/D. Command editing and recall is possible, unless taql was built without readline support. Of course, a ï¬le can be used as input by redirection to stdin. This is more or less the same as using -f, but a command cannot be split over multiple lines and no semicolon is needed to separate commands. Interactive commands are kept in $HOME/.taql_history making command recall possible across multiple taql sessions.
    A few types of commands can be given:
    • help, h or ? shows brief help information.
    • show can be used to show to available units or measure types.
    • A full TaQL command. If no GIVING part is given, the resulting table is not made persistent. It shows the number of matching rows.
    • A full TaQL command preceded by varname=, where varname is the name under which the resulting table is kept in this session. Thus the result is not a persistent table (unless GIVING was given), but it is kept temporarily. The varname can be used in subsequent commands like SELECT FROM $varname.
    • varname= without a further command removes the temporary result.
    • varname shows the number of rows in the temporary result. It can be followed by one or more question marks to show the column names and details about them.
      Note that if an unknown varname is given, it is treated as a TaQL command resulting in a parse error.
    • Comments can be given after the hash (#) character. Empty lines are ignored.

If columns are selected in the TaQL command, their values are printed. By default they are separated by tabs, but the -d option can be used to deï¬ne another delimiter. Epoch, position, and direction measures are printed in a formatted way. Note that TaQL’s str function offers nice formatting for any value. Also the result of CALC commands is printed. Otherwise only the number of selected (or updated or deleted) rows is printed. Options like -nops can be given to suppress printing the results.

By default the program taql uses the Python style. The -s option can be used to specify a style.

13.4 C++ interface

The C++ programmer can use TaQL commands and expressions at various levels,

13.4.1 TaQL query string

The function tableCommand in TableParse.h can be used to execute a TaQL command. The result is a Table object. E.g.,

  Table seltab1 = tableCommand  
         ("select from mytable where column1>0");  
  Table seltab2 = tableCommand  
         ("select column1,column2 from $1 where column2>5"  
          " orderby time giving result.tab", seltab1);

These examples do the same as the Python ones shown above.
Note that in the second function call the table name $1 is replaced by the object seltab1 passed to the function.
There is no style argument, so if an explicit style is needed it should be the ï¬rst part of the TaQL statement. Note that the Glish style is the default style.

13.4.2 Expression string

The function parse in RecordGram.h can be used to parse a TaQL expression. The result is a TableExprNode object that can be evaluated for each row in the table. E.g.

  Table tab("mytable");  
  TableExprNode expr = RecordGram::parse (tab, "column1>0");  
  Table seltab1 = tab(expr);

The example above does the same as the ï¬rst example in the previous section. There are, however, better ways to use this functionality.

  Table tab("somename");  
  TableExprNode expr = RecordGram::parse (tab, "ANTENNA1=1");  
  for (uInt row=0; row<tab.nrow(); ++row) {  
    if (expr.getBool(row)) {  
      // expression is true for this row, so do something ...  
    }  
  }

The example above shows a boolean scalar expression, but it can also be a numeric expression or an array expression as shown in the example below. Note that TaQL expression results have data type Bool, Int64, Double, DComplex, String, or MVTime.

  TableExprNode expr = RecordGram::parse (tab, "abs(DATA)");  
  Array<Double> data;  
  for (uInt row=0; row<tab.nrow(); ++row) {  
    expr.get (row, data);  
  }

Class RecordGram can also be used to apply TaQL to C++ vectors of values or Records. The RecordGram class documentation and its test program describe these features in more detail.

13.4.3 Expression classes

The other expression interface is a true C++ interface having the advantage that C++ variables can be used directly. Class Table contains functions to sort a table or to select columns or rows. When selecting rows class TableExprNode (in ExprNode.h) has to be used to build a WHERE expression which can be executed by the overloaded function operator in class Table. E.g.

  Int limit = 0;  
  Table tab ("mytable");  
  Table seltab = tab(tab.col("column1") > limit);

does the same as the ï¬rst example shown above. See classes Table, TableExprNode, and TableExprNodeSet for more information on how to construct a WHERE expression.

14 Writing user deï¬ned functions

A C++ user deï¬ned function has to be written as a class derived from the abstract base class UDFBase. The documentation of this base class describes how to write a UDF. Furthermore one can look at class UDFMSCal that contains the UDFs described in subsection User deï¬ned functions.

It is possible to write a UDF that operates on an individual expression (for each table row) and returns the result. It is, however, also possible to write a UDF acting as an aggregate function. In that case it will return a result based on the values of all rows in a group. See the desription of the GROUPBY clause for more information on the GROUPBY clause and aggregate functions.

Note that a class can contain multiple UDFs as done in UDFMSCal. Also note that a single UDF can operate on multiple data types which is similar to a function like min that can operate on scalars and arrays of different data types.

A UDF class can contain a HELP function, which should return help information. This function is called by a help command like

   show function meas [subtype]

It returns an overview of the functions in the UDF class and possible other information. The optional subtype argument can be used to return more speciï¬c information. Note that the same result is given by

   meas.help(’subtype’)

TaQL ï¬nds a UDF by looking in a dictionary mapping the UDF name to a function constructing an object of the UDF class. If not found, it tries to load the shared library with the lowercase name of the library part of the UDF (like in derivedmscal.pa1). If the load is successful, it calls an initialization function in the shared library that should add all UDF functions in the library to the dictionary. The description of the UDFBase class shows how this should be done.

14.1 UDFs in Python

NOTE: This section is for a future version of TaQL. It has not been fully implemented yet.

For performance reasons User Deï¬ned Functions will usually be implemented in C++. It is, however, possible to implement them in Python, both regular functions and aggregate functions. This can be done by means of the pytaql module of Casacore.

A UDF has to be implemented in Python by subclassing pytaqlbase, that can be imported from Casacore.python. The subclass has to implement a few functions, some are optional. The functions are called in the order given below.

  • __init__(self)
    The class constructor must call the __init__ function of the superclass.
  • needTable(self)
    This optional function tells if the UDF needs the Table object of the table being queried. If True is returned, the function setTable is called thereafter. The Table object can be used by UDFs needing extra info (e.g., keywords) from the table being queried or from its subtables (comparable to derivedmscal). It requires the import of pyrap.tables at the beginning of the UDF script.
  • setTable(self, tab)
    This function makes it possible to keep the Table object. It must be implemented if needTable returns True. The object should be kept like:
        self.tab = pyrap.tables.table (tab, _oper=3)

  • setup(self, valuetypes, datatypes, units)
    This function is called once at the beginning. It gets the value types, data types, and units of the function arguments. The length of the sequences tells the number of arguments.
     valuetypes  int seq   value type of each argument  
                           0=scalar 1=array 2=set  
     datatypes   int seq   data type of each argument  
                           0=bool 1=int 2=float 3=complex  
                           4=string 6=date  
     units       strings   unit of each argument (empty=no unit)

    The UDF should check if the argument types are correct and determine the result type. It has to return a dict containing the following ï¬elds:

     ndim      int       dimensionality of result  
                         -1=scalar 0=unknown  
     shape     int seq   shape (if fixed, otherwise empty sequence)  
     dtype     int       data type of result  
     unit      string    optional unit of result  
     isaggr    bool      True = UDF is aggregate function

  • getValue(self, argValues, rownr)
    This function must return the function value for the given argument values. It is only called if setup does not set isaggr=True. Normally the rownr argument is not needed, but it could be used to obtain special info from the Table object for that row.
  • getAggrValue(self, rownrs)
    This function must return the value of the aggregate function for the given rows. The argument values are not passed, because their sizes may exhaust memory. Instead the list of row numbers in the aggregation group are given. For each row the following function must be called to get a list of the argument values for that row.
        getArgValues(self, rownr)

Such a UDF can be called in TaQL like py.module.class where the class defaults to the module name.
An example of UDFs in Python is given below. The ï¬rst one is a regular UDF, the second one an aggregate UDF.

# tpytaql.py: Test script for pytaqlbase  
 
from casacore.pytaqlbase import pytaqlbase  
##import pyrap.tables as pt  
 
class tpytaql(pytaqlbase):  
    """  
    A test (and example) for a pytaql UDF.  
    It returns the sum of the values in the argument.  
    """  
 
    def __init__(self):  
        """ The constructor must call the __init__ in the base class. """  
        pytaqlbase.__init__(self)  
 
    def setup(self, valuetypes, datatypes, units):  
        """ Setup the pytaql object. """  
        if len(valuetypes) != 1:  
            raise ValueError("UDF tpytaql should have exactly 1 argument")  
        self.isScalar = valuetypes[0]==0  
        return {’ndim’:0, ’dtype’:datatypes[0], ’unit’:units[0]}  
 
    def getValue(self, argValues, rownr):  
        """ Get the value of the function for the given table row. """  
        if self.isScalar:  
            return argValues[0];  
        return argValues[0].sum()    # sum of numpy array  
 
 
 
class tpytaqlaggr(pytaqlbase):  
    """  
    A test (and example) for a pytaql aggregation UDF.  
    It returns the difference of the total of both arguments.  
    """  
 
    def __init__(self):  
        """ The constructor must call the __init__ in the base class. """  
        pytaqlbase.__init__(self)  
 
## The following functions show how to get and keep a Table object.  
## Note the import of pyrap.tables is also required.  
##    def needTable(self):  
##        return True  
##    def setTable(self, tab):  
##        self.tab = pt.table(tab, _oper=3)  
##        print "nrows",self.tab.nrows()  
 
    def setup(self, valuetypes, datatypes, units):  
        """ Setup the pytaql object. """  
        if len(valuetypes) != 2:  
            raise ValueError("tpytaqlaggr UDF should have exactly 2 arguments")  
        self.isScalar0 = valuetypes[0]==0  
        self.isScalar1 = valuetypes[1]==0  
        return {’ndim’:0, ’dtype’:datatypes[0],  
                ’unit’:units[0], ’isaggr’:True}  
 
    def getAggrValue(self, rownrs):  
        """ Get the value of the aggregate function for the given table rows. """  
        v = 0;  
        for rownr in rownrs:  
            argValues = self.getArgValues (rownr);  
            if self.isScalar0:  
                v += argValues[0];  
            else:  
                v += argValues[0].sum()  
            if self.isScalar1:  
                v -= argValues[1];  
            else:  
                v -= argValues[1].sum()  
        return v

15 Possible future developments

In the near or far future TaQL can be enhanced by adding new features and by doing optimizations.

  • Add ROLLUP/CUBE to the GROUPBY clause.
  • Implement the OVER/PARTITION clause.
  • Add explicit JOIN clause (probably only equi-joins).
  • Add UNION, INTERSECTION, and DIFFERENCE.
  • Handle invalid subexpressions (e.g., exceeding array bounds) as null arrays which can be tested with the function ISNULL.
python-casacore-2.2.1/doc/259.css000066400000000000000000000123671320311315100164100ustar00rootroot00000000000000 /* start css.sty */ .cmr-10{font-size:90%;} .cmr-10x-x-109{} .cmr-17{font-size:154%;} .cmr-12{font-size:109%;} .cmbx-10{font-size:90%; font-weight: bold;} .cmtt-10x-x-109{font-family: monospace;} p.noindent { text-indent: 0em } td p.noindent { text-indent: 0em; margin-top:0em; } p.nopar { text-indent: 0em; } p.indent{ text-indent: 1.5em } @media print {div.crosslinks {visibility:hidden;}} a img { border-top: 0; border-left: 0; border-right: 0; } center { margin-top:1em; margin-bottom:1em; } td center { margin-top:0em; margin-bottom:0em; } .Canvas { position:relative; } img.math{vertical-align:middle;} li p.indent { text-indent: 0em } .enumerate1 {list-style-type:decimal;} .enumerate2 {list-style-type:lower-alpha;} .enumerate3 {list-style-type:lower-roman;} .enumerate4 {list-style-type:upper-alpha;} div.newtheorem { margin-bottom: 2em; margin-top: 2em;} .obeylines-h,.obeylines-v {white-space: nowrap; } div.obeylines-v p { margin-top:0; margin-bottom:0; } .overline{ text-decoration:overline; } .overline img{ border-top: 1px solid black; } td.displaylines {text-align:center; white-space:nowrap;} .centerline {text-align:center;} .rightline {text-align:right;} div.verbatim {font-family: monospace; white-space: nowrap; } table.verbatim {width:100%;} .fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } table.minipage{width:100%;} div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;} div.center div {text-align: left;} div.flushright, div.flushright div.flushright {text-align: right;} div.flushright div {text-align: left;} div.flushleft {text-align: left;} .underline{ text-decoration:underline; } .underline img{ border-bottom: 1px solid black; margin-bottom:1pt; } .framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } .framebox-c {text-align:center;} .framebox-l {text-align:left;} .framebox-r {text-align:right;} span.thank-mark{ vertical-align: super } span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; } div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; } table.tabular td p{margin-top:0em;} table.tabular {margin-left: auto; margin-right: auto;} div.td00{ margin-left:0pt; margin-right:0pt; } div.td01{ margin-left:0pt; margin-right:5pt; } div.td10{ margin-left:5pt; margin-right:0pt; } div.td11{ margin-left:5pt; margin-right:5pt; } table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } td.td00{ padding-left:0pt; padding-right:0pt; } td.td01{ padding-left:0pt; padding-right:5pt; } td.td10{ padding-left:5pt; padding-right:0pt; } td.td11{ padding-left:5pt; padding-right:5pt; } table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } .hline hr, .cline hr{ height : 1px; margin:0px; } .tabbing-right {text-align:right;} span.TEX {letter-spacing: -0.125em; } span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;} a span.TEX span.E {text-decoration: none; } span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;} span.LATEX span.TEX{ position:relative; left: -0.4em; } div.float img, div.float .caption {text-align:center;} div.figure img, div.figure .caption {text-align:center;} .marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;} .marginpar p{margin-top:0.4em; margin-bottom:0.4em;} table.equation {width:100%;} .equation td{text-align:center; } td.equation { margin-top:1em; margin-bottom:1em; } td.equation-label { width:5%; text-align:center; } td.eqnarray4 { width:5%; white-space: normal; } td.eqnarray2 { width:5%; } table.eqnarray-star, table.eqnarray {width:100%;} div.eqnarray{text-align:center;} div.array {text-align:center;} div.pmatrix {text-align:center;} table.pmatrix {width:100%;} span.pmatrix img{vertical-align:middle;} div.pmatrix {text-align:center;} table.pmatrix {width:100%;} img.cdots{vertical-align:middle;} .partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;} .caption td.id{font-weight: bold; white-space: nowrap; } table.caption {text-align:center;} h1.partHead{text-align: center} p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; } p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; } .paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;} .subparagraphHead, .likesubparagraphHead { font-weight: bold;} .quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;} .verse{white-space:nowrap; margin-left:2em} div.maketitle {text-align:center;} h2.titleHead{text-align:center;} div.maketitle{ margin-bottom: 2em; } div.author, div.date {text-align:center;} div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; } div.author{white-space: nowrap;} .quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; } .abstract p {margin-left:5%; margin-right:5%;} table.abstract {width:100%;} .figure img.graphics {margin-left:10%;} /* end css.sty */ python-casacore-2.2.1/doc/259.html000066400000000000000000000525771320311315100165730ustar00rootroot00000000000000 NOTE 259: pyrap binding to casacore

NOTE 259: pyrap binding to casacore

Ger van Diepen, ASTRON Dwingeloo

November 10, 2006

Abstract

pyrap is a Python binding to casacore classes using Boost.Python. It consists of a set of standard converters and bindings to the classes. As much as possible the bindings are the same as in glish.

Contents

1 Introduction

Since long glish bindings to the casacore system have been in place. Quite recently Python bindings have been created in the general casapy framework using tools like CCMTools, Xerces, Xalan, and IDL. Albeit very flexible, it is quite complicated and it is not straightforward to build on other systems than RedHat and OS-X.

Therefore an attempt has been made to make a simpler Python binding using Boost.Python. This proved to be very easy and succesful. The binding consists of two parts:

  • Converters to translate objects between Python and C++.
  • Class wrappers to map a C++ class and its functions to Python.

The Python numarray and numpy (version 1.0 or higher) packages are supported. At build time one can choose which ones should be used.

2 Converters

Boost.Python offers a nice way to convert objects to and from Python. Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of Lawrence Berkeley National Laboratory has built converters for standard STL containers. This has been extended to convert to/from other objects.
The following C++ objects are currently supported:

  • scalars (bool, integer, real, complex)
  • std::string
  • casa::String
  • std::vector<T>
  • casa::Vector<T>
  • casa::IPosition
  • casa::Record
  • casa::ValueHolder
  • exceptions (casa::IterError and std::exception)

These C++ objects can usually be created from several types of Python objects and are converted to a specific Python object.

  • A vector or IPosition object is converted to a Python list.
    It can be constructed from the following Python objects:
    • scalar
    • list or tuple
    • numarray scalar or 1-dim array
    • numpy scalar or 1-dim array

    Note that a list or tuple of arbitrary objects can be given. For example, it is possible to get a Vector<TableProxy> from Python.

  • A casa::Record is mapped to a Python dict.
  • Every C++ exception is mapped to a Python RunTimeError exception. However, casa::IterError is special and is mapped to an end-of-iteration exception (StopIteration) in Python.
  • A casa::ValueHolder is a special casacore object that can hold a record or a scalar value or n-dim array of many types (bool, numeric, string). It is meant to conceal the actual type which is useful in functions that can accept a variety of types (like getcell in the table binding).
    Converting a ValueHolder to Python creates the appropriate Python scalar, array, or dict object. When converting from Python to ValueHolder, the appropriate internal ValueHolder value is constructed; a list, tuple, and array object are converted to an casacore array in the ValueHolder.

It means there is no direct Array conversion to/from Python. A ValueHolder object is always needed to do the conversion. Note that this is a cheap operation, as it uses Array reference semantics. ValueHolder has functions to convert between types, so one can get out an Array with the required type.

2.1 Array conversion to/from numpy and numarray

casacore arrays are kept in Fortran-order, while Python arrays are kept in C-order. It was felt that the Python interface should be as pythonic as possible. Therefore it was decided that the array axes are reversed when converting to/from Python. The values in an IPosition object (describing shape or position) are also reversed when converting to/from Python.
Note that although numarray and numpy have Fortran-array provisions by setting the appropriate internal strides, they do not really support them. When adding, for instance, the scalar value 0 to a Fortran-array, the result is a transposed version of the original (which can be a quite expensive operation).

A function binding could be such that shape information is passed via, say, a Record and not via an IPosition object. In that case its values are not reversed automatically, so the programmer is responsible for doing it.

An casacore array is returned to Python as an array object containing a copy of the casacore array data. If pyrap has been built with support for only one Python array package (numpy or numarray), it is clear which array type is returned. If support for both packages has been built in, by default an array of the imported package is returned. If both or no array packages have been imported, a numpy array is returned.
Note that there is no support for the old Numeric package.

An casacore array constructed from a Python array is regarded as a temporary object. So if possible, the casacore array refers to the Python array data to avoid a needless copy. This is not possible if the element size in Python differs from casacore. It is also not possible if the Python array is not contiguous (or not aligned or byte swapped). In those cases a copy is made.

A few more numarray/numpy specific issues are dealt with:

  • An empty N-dim casacore array (i.e. an array containing no elements) is returned as an empty N-dim Python array. If the dimensionality is zero, it is returned as an empty 1-dim array, to prevent numarray/numpy from treating it as a scalar value.
  • In numarray array() results in Py_None. This is accepted by the converters as an empty 1-dim array.
  • Empty arrays can be constructed in Python using empty lists. For example, array([[]]) results in an empty 2-dim array. The converters accept such empty N-dim Python arrays. The type of an empty array is set to Int by numarray and to Double by numpy.
  • Because the type of an empty Python array cannot easily be set, the converters can convert an empty integer or real array to any type.
  • The converters accept a numpy string array. However, it is returned to Python as the special dict object described above.

3 Class wrappers

Usually a binding to an existing Proxy class is made, for example TableProxy, which should be the same class used in the glish-binding. For a simple binding, only some simple C++ code has to be written in pyrap_xx/src/pyxx.cc, where XX is the name of the package/class.
// Include files for converters being used.  
#include <casacore/python/Converters/PycExcp.h>  
#include <casacore/python/Converters/PycBasicData.h>  
#include <casacore/python/Converters/PycRecord.h>  
// Include file for boost python.  
#include <boost/python.hpp>  
 
using namespace boost::python;  
 
namespace casa { namespace pyrap {  
  void wrap_xx()  
  {  
    // Define the class; "xx" is the class name in Python.  
    class_<XX> ("xx")  
      // Define the constructor.  
      // Multiple constructors can be defined.  
      // They have to have different number of arguments.  
      .def (init<>())  
      // Add a .def line for each function to be wrapped.  
      // An arg line should be added for each argument giving  
      // its name and possibly default value.  
      .def ("func1", &XX::func1,  
            (boost::python::arg("arg1"),  
             boost::python::arg("arg2")=0))  
    ;  
  }  
}}  
 
BOOST_PYTHON_MODULE(_xx)  
{  
  // Register the conversion functions.  
  casa::pyrap::register_convert_excp();  
  casa::pyrap::register_convert_basicdata();  
  casa::pyrap::register_convert_casa_record();  
  // Initialize the wrapping.  
  casa::pyrap::wrap_xx();  
}

Python requires for each package a file __init__.py, so such an empty file should be created as well.

3.1 More complicated wrappers

Sometimes a C++ function cannot be wrapped directly, because the argument order needs to be changed or because some extra Python checks are necessary. In such a case the class needs to be implemented in Python itself.
The C++ wrapped class name needs to get a different name, usually by preceeding it with an underscore like:
    class_<XX> ("_xx")

The Python class should be derived from it and implement the constructor by calling the constructor of _xx.
class xx(_xx):  
    def __init__(self):  
        _xx.__init__(self)

Now xx inherits all functions from _xx. The required function can be written in Python like
    def func1 (self, arg1, arg2):  
        return self._func1 (arg2, arg1);

Note that in the wrapper the function name also needs to be preceeded by an underscore to make it different.

3.2 Combining multiple classes

Sometimes one wants to combine multiple classes in a package. A example is package pyrap_tables which contains the classes table, tablecolumn, tablerow, tableiter, and tableindex. One is referred to the code of this package to see how to do it.

4 Python specifics

Besides an array being in C-order, there are a few more Python specific issues.

  • Indexing starts at 0 (vs. 1 in glish).
  • The end value in a range like [10:20] is exclusive (vs. inclusive in glish). Furthermore Python supports a step and reversed ranges.
  • Where useful, the function __str__ should be added giving the name of the object. This function is used when printing an object.
  • Where useful, the functions __len__, __setitem__(index, value), and __getitem__(index) should be added to make it possible that a user indexes an object directly like tabcol[i] or tabcol[start:stop:step].
  • When these functions are added, Python supports iteration in an object. Explicit iteration can also be done by adding the functions __iter__ and next. At the end next should raise the Python StopIteration exception (or throw casa::IterError when implemented in C++) to stop the iteration.
python-casacore-2.2.1/doc/259.latex000066400000000000000000000012531320311315100167250ustar00rootroot00000000000000\documentclass[11pt]{article} \usepackage{hyperref} \usepackage[dvips]{graphicx, color} %%----------------------------------------------------------------------------- \begin{document} \title{NOTE 259: pyrap binding to casacore} \author{Ger van Diepen, ASTRON Dwingeloo} \date{November 10, 2006} \maketitle \begin{abstract} pyrap is a Python binding to casacore classes using Boost.Python. It consists of a set of standard converters and bindings to the classes. As much as possible the bindings are the same as in glish. \end{abstract} %%--------------------------------------------------------------------------- \tableofcontents \newpage \input{pyrap.tex} \end{document} python-casacore-2.2.1/doc/259.pdf000066400000000000000000002223221320311315100163630ustar00rootroot00000000000000%PDF-1.4 %ÐÔÅØ 5 0 obj << /S /GoTo /D (section.1) >> endobj 8 0 obj (Introduction) endobj 9 0 obj << /S /GoTo /D (section.2) >> endobj 12 0 obj (Converters) endobj 13 0 obj << /S /GoTo /D (subsection.2.1) >> endobj 16 0 obj (Array conversion to/from numpy and numarray) endobj 17 0 obj << /S /GoTo /D (section.3) >> endobj 20 0 obj (Class wrappers) endobj 21 0 obj << /S /GoTo /D [22 0 R /Fit ] >> endobj 24 0 obj << /Length 494 /Filter /FlateDecode >> stream xÚuSMoÛ0 ½çWè(µ*ɲ$÷–®Øí°ù6ô 8jb ±KÍÐ?ÊÒC/¦Hññ‘O4';ÂÉãŠaoÛÕõƒÐD&E­Hû Gɬ1DsÃj)I»%èÓs{_”—TÖÍMQ*®é©š¾Oî„›~ØöÃ8¢í\pÝ8ùâ¥ýD†Ášº–‰¨RÌ(C U"ó<ú €P÷\ÔŠº»Þ‰4ÔW)bèúwû«–>?¡÷¨ýaœ³ÆÄF”eF6¤”Š©Úæ1ÆîÏéã ¿Á²Vü %ç:ùO¯ë©Ià FšYP ä`Ò(äXoBœ\¿ÀÛOðRˆš‰FÂÁ2a³§ÔXÖšêöäÐýù÷cÖåCrpfÉ!á"9z‚Ï%ÞBÎ6ô6Ieé"Êl­Š5J¥ÎÒ;aCß#`”¢Ý8„>Ä€ÞøŠÖ¡ >.ã!ºaë¦í›Æ:§Ÿ¢ŸrÈÁCž%‡ça’ÝûŒÇ9°K¾ìo@UEé]ߺD±Çˆ›oÅíCè7!¬ 9ŸˆbºÜ‚æspG¿,Øèï}Ø3Üni ¨W)=o7ÂNT°Þ3ùi¿ • Ñ£ ‹I»!8kx#ð?ÔL'xŸ®/€ûvõT¶õ% endstream endobj 22 0 obj << /Type /Page /Contents 24 0 R /Resources 23 0 R /MediaBox [0 0 612 792] /Parent 33 0 R >> endobj 25 0 obj << /D [22 0 R /XYZ 125.798 687.123 null] >> endobj 26 0 obj << /D [22 0 R /XYZ 125.798 662.217 null] >> endobj 32 0 obj << /D [22 0 R /XYZ 125.798 425.211 null] >> endobj 23 0 obj << /Font << /F16 27 0 R /F17 28 0 R /F26 29 0 R /F8 30 0 R /F28 31 0 R >> /ProcSet [ /PDF /Text ] >> endobj 39 0 obj << /Length 1412 /Filter /FlateDecode >> stream xÚ½WÝ“Ó6ç¯È£3cÙqß0Lá ”–¶”ËPfJt¶’¨çX®$“Ëß]í:—„L? ðk¥Õ~ïo•d´%£÷þ>]Ü{ø<Ä4Φ³t´XŽDšÇE9Ír§ù|´¨G¿Eb<p½lÇ™ˆ¼5ã |ë¾òÚ´ãßß?|B’¸LJB’Ñ$‘yJׯt[)¸’Ϣƴ+Z­íÖ´¼Öm­Û•#Êþ®ùN%¬ŒeÊíœW\ÑZŽÓyôøôz8PpúádŸJXï«íòþýøo]š°}äÓì“|j¤cë¶VvYhyËs„7€OdÛÞ2:¨î®ïÍÖžã²ìÛ0"Ž„ ¾RA!Åi‘g%”F&òƒÏ£ãÕo¤µ’¡wI)Ïá¸C.>{Ÿä çÊéAŒˆ\ÌZic `¢,ð ¢;Yá›qÒWʱjj˜?}793:(nŠ¢Æú |Š1ÀAo†òhÇp€œ x=´&³m׺B§Öû[N·6ý • ‹äõcùx¸ƒÉPÏå”Ç:–u† ?\Öÿ8Ó?pºÌ#Å—…êAJâgµû7¬9E¸%ßÊ„ôÅÂŽúç=dE/­ÙÐÖaQ ÈÙräÉ,ú5¦ï kœS“úÖùFñ>gÉQ«dYÀ î•Gv»ºùf'ׯÄ0¹Ÿ SYÄj‚/Öû*”ìÖªð§Êº7jG;?É wD–@+”'s Ÿ Ó¤iÀÆJoxq3Ì\`­a“ùiT)/À²ÄÚGç!’axâöÕâ-*Â9/5.|šgw%8Z@ü[fVa8…!€—ÕO Ê:¡ÄCÊj¨vÚ'hz6Í„À¹4McPæ6ÌÄ)eÈ:ËÔÜhPo­ 1 /ÀÐe}7ôöÞ™V_zÖ¸ ^e #’Q|‡‡Ü†ZJ”Z)û€Ü„WçpWê6@Ûÿ1ENzãØ\__\ÀÓŒù¿Ô•’.|._\\ýWeŸáبc-quäÛÛOÐ÷9±|ùÚ8=ü™û þ½Qð‡®þJν•M¯¾3M Hò…Sê¶RÝÁ‹ûöÜ\É‹ŽOrøüÌZcÏL•y 0·Ÿ*8ýÎMá»HêvoÏ9™I,æb`ÿ$F“r—SÀ°iOólx2ò<[Üû Sè endstream endobj 38 0 obj << /Type /Page /Contents 39 0 R /Resources 37 0 R /MediaBox [0 0 612 792] /Parent 33 0 R /Annots [ 34 0 R 35 0 R 36 0 R 43 0 R ] >> endobj 34 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [279.745 623.788 321.222 635.478] /Subtype/Link/A<> >> endobj 35 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [152.443 542.493 219.951 554.182] /Subtype/Link/A<> >> endobj 36 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [369.629 375.271 485.45 387.264] /Subtype/Link/A<> >> endobj 43 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [124.802 362.025 212.072 373.715] /Subtype/Link/A<> >> endobj 40 0 obj << /D [38 0 R /XYZ 125.798 687.123 null] >> endobj 6 0 obj << /D [38 0 R /XYZ 125.798 662.217 null] >> endobj 10 0 obj << /D [38 0 R /XYZ 125.798 432.405 null] >> endobj 37 0 obj << /Font << /F28 31 0 R /F8 30 0 R /F29 41 0 R /F30 42 0 R >> /ProcSet [ /PDF /Text ] >> endobj 49 0 obj << /Length 1890 /Filter /FlateDecode >> stream xÚ½XKoÛF¾çWèH!&Ã}ð•Ü nÜCa¤BzhzXS+‹)Eª$ÛèŸïÌÎð%3 ’½ˆ»³y3«pu· W¿< ùûóæÙ‹«t% 3±ÚìVBFA’¥«8ŒÒÕf»úÓÛìmk×¾ÖÂ{õü9¤Wß®ý(ò>ؼk‰’›ŠöœÚ“)ËGšÀ6™z|:o¬éì–öïšú@äÖ~\ã¦Æ”´ÔáôñGÏòõõŽ6ßdzáµn‹3=‘_¤ázöÛ¢kLóÈ+“è#Š t 膓»‚Rª ©„ò®Ö©8Ùs^KÀUp@P‚j€¯nÛâ¶´óä¼³]Ÿ¥pÑ‹+Î!nQoÛw(~ܸ榩¢Cg0ƒ?âþ̘œ”€ŸÇ5°¼€áÌßl¹iÍË—om^7Û9\Ì‘qx†Ò TzÛâKHì3÷ïø5#'V¸PqI %ˆžöHPŒ+¨ n©‚ ¨ .úÜÀ᡼;WÊ4±ê¥x{ª6ÅÁ¾nšºYpk¢!‘íCn>%Œ E R9A”5 û†€ØéÈš^,É¢Arßug›O ”f{ó~ç\)'%k?R¨XK5l™û_’Ñh'}mµeÕD,ƒ,ÒgmÁÎ/@.ÓWFEÖ åû0 —³)›"Õï]}¼.Z°¸t4(— ÎêjŒSðïSJdQð}z‰ø¡Ù'ïÖ)`fy²oêrkZBÛâ1Qg^èÏB*ZZŸ -3´&\ó‘´‡ë‰dˆÐP./5j(E&ÜFøôxãkàƒÒÒ´ßYüË,døO°XàÔÁ6ì8˜ŠKÎ:Ú!…a…´Ý©Ê1"ÛžxfAZîÍÀ;9ÿ¬Ï£GT÷ Ë–£â»cÀ}jÍ>oÊâo‹ùë VCþ@éÊmY.dŽVÓ TTgÍag¸ *¨ËÕ¶˜úÄ—a ­µšõ£¯æ .µ”qêÔïÖåiFàšXª Ðè¹ÒÒ‰ƒ·M}l ÓÙÙ‘£SdcDéhÒ·{¦¹öFSݢѤkG<†túco+ZË—ôÒCC­'M³f˜Ú ®¿$"Ùà;–ˆuÌÎu„)(´mS9œÊ\Aâ$}Ý©–®›<~NJRûr. ögÎ0!5f<æç[æÍú×ìü“õÏ»lù…“qãQápm\r ·S¦Î& ²žQÉðüÞy'´vøÐÒîtЪ‰á[ÕôÝ ¡,Œ/G‰p:jo«¦uõËÝV¿ØArº Ày߸9—^íÜ[OqO_ÏpA”Rï_Sº–€°—i•µ[×ÊD”@øÝºoF±„„¹3Zj4R‘q§N{ sëö=¿/m!8´æ¸XP˜¨6cØÄàO—¸’ºëÿ–°L¹K.4vÕÖPó"oAÜH… ›÷=—†äs¶‘â<.‰Èoˆnìº0ßqeVÚ ú¤å»êÊò¥îÒÛÀ-xЯL É÷t"ÄÁ9 v4öŸDÞb¹ž‰~ËßqYIp8 ³@H~þÉZ!dDŒ•p–N"§¿Â"ÐG0Ò1‚ Ã`â¶à‹p‘\ endstream endobj 48 0 obj << /Type /Page /Contents 49 0 R /Resources 47 0 R /MediaBox [0 0 612 792] /Parent 33 0 R /Annots [ 44 0 R 45 0 R 46 0 R ] >> endobj 44 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [304.485 394.713 345.962 406.402] /Subtype/Link/A<> >> endobj 45 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [383.733 299.868 425.21 311.558] /Subtype/Link/A<> >> endobj 46 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [124.802 160.369 166.279 172.059] /Subtype/Link/A<> >> endobj 50 0 obj << /D [48 0 R /XYZ 125.798 687.123 null] >> endobj 14 0 obj << /D [48 0 R /XYZ 125.798 195.908 null] >> endobj 47 0 obj << /Font << /F8 30 0 R /F29 41 0 R /F26 29 0 R /F30 42 0 R /F28 31 0 R >> /ProcSet [ /PDF /Text ] >> endobj 59 0 obj << /Length 2306 /Filter /FlateDecode >> stream xÚµYK“ܶ¾ï¯˜#§JÃ%H€Ü⊕(•oU²‰A2CŽùÐZþõîF78 ‡ÚØ®ò‰@£4úñ¡LvÇ]²ûûCÂßïžß–;‘ÄUR‰ÝÓóN¤*.ªr—+§ªÜ=5»ÑpÒ×ý!-#³?dYu=}‰Ø v´]ûc¢‘uïød¤ÏCG¤Þ|Ùãü~0 ½œLKcu×â1ì"ê÷"m{$Ʊ{|î» ñ~ø:žº6Þzú'à ²XÉŠ„|ßnÛ*Oz„–L@`ŸŽ'¢»m¦‹î{­¯ÌÓ6‹ák0vÒ¡dÈôv_âùÇ^·‡ÕBW”»Û§EôÅ f|&–@bÅZ5#R¦9Èl¨¡¯×¾»öVL°N®Ñô­>e{Û˜á ô$žÖ|%zãöwͶ©Ñ}>óø0]Ùbý8ïzÙTæœudVFºi@HÜ+—Ñ3Z^f5Œº­ ÓIzàj}Ö=µ¿ìç<ñPBŸ±ãuéú”÷ú¯WîÍaKÐa:;[—‘E}ƒ>4uqÅÁ;¨s:é,Y ‚uˆÐ=37nƒ³»Þ­Ó4’Á§“—“­Qª1Ôš§~ž#B–´iý4Ù‘)æg™v°ì@âwÌÔkBd‘ÇUV,yÿ «"zžÚz¤(¶ … ÕÝtn˜ëN:è Ó|…g?q‚Cah+4,Øø¢o8µÂÀU¤F }±úóÊéÝzaÃL‚ ïãÛ, &KâLT 7éߦîú†øx”•±ʳQ¬JIþ :íÖ.…Œ“*÷Óß}`¬ÚØH©8½qv ?ðÞÿšzŒÁÿŠ\$xÂ`¨eÇ¥Ù+å\~`¡zÃzªŠ¸Ló¥Aé‹:ÂÄiìÐ µ‹^V%Ð=ž’¿:^Á–}wìõåÂØéÆÕÜÊ>À ?Ÿ¿Ÿ À%!ÆŒ´v|ÅùðøE‰‡Ö5nÔ!Úáz„\„Ðu›²ãÔ·îH>Ž„M¼€ï/rVPÎ Dà«bÔ¶E©ï\ÐK‹>‘a<\Q¯_©çb¾¬;>KG—UÁ{ÏÜ5š\ÿO¤›¡Ç€Áé''=Ð è>ƒîd&Ë‹OD\b/RÐ[ˆÐ"\§…‚–Á†œ5†Ä@C8tc€ÌÿsP{4㨵ºÌÜz=ÍY\ƒp^D7(Ü5#± qJ}6º§fƒK9î/¶Ñ £Ú»ÄB³å7´ã†H¹×£;p‰Vxàá5S”7S °½YÜÇn¼1Ïz?¦ SèÖGqpÏK¾3| BÃ^fáé¢ÉÖb2£B¨P¶S¬KM'Åmzân» )²µå‡­¬Ó¹ÔÏJr†MŸ›qH,%˜1FÇy%+›3swzo–8å Cì…wéa†<ȾΠ’ï§Ëœ/‚sΊç€Ñë & ö‚cºA€Î±Ÿjg[$P6ê8ñ“Ìñ¹1χßÞußøôàçëÍlÝãZB†hž“—EôæRBEö™8XuƒƒzL 2Å ”á!¡Ê +ôænrš·™|¾­ =¢r˜IåÀ>ÃdÌ;`gÒœmÓœÍÀ<#5dƒy=,gЖ™ø¾¬–çdFö’*2gs1t[0ÆØ_6S0ëà^‚vcLDæ4‚]®?T5+dT©ˆÞD¶ÌÈ´HVUÍ5’—U±¬ªbYW[oë,+î# ^]äó…hS7ñ ¿ ‘{F¸ÝÎöHW1Pi´`(t ½á»š‘Ø4”‚U”ü¬º¹1ûá µ—e.€h7é¢óz†‹é‰y¡`¾t'Ö¥Ûc‹î‚Ð}Á¿°Ä ©Ñ†²ö83PR†U©_´Úˆ30¼¨ÿ‚rÍ¥ñãÛ´ óÃC«"ÛÒ$v”6(V“–Å´kúœÑ&-ÓB{ô×2tß{Á¦¸O®p<¼ñ¡‹Öµ1:  èv“i•'9B,nâ7!–ÁÕíßð5)ª ‹Ãžf*nŒ_:LA8RùÃ`sFE:5¤² z‘wíÉ4ð¿ ÄÝë¥ 0;¾2WÑ/¦ïåªÒ%.HòCÐÐÓLuBÃ7°v «è®­¸b…±«Äð¨‚DòCpÌÍê4ðÖõez{Ó¡F÷Ï™;‰óÒaqû‡æÂ:~ÝcÙý©‰ò?â²÷²¼¿­R+Ïc•”s¥¬˜Y&Þ½VûHÚyn(S Žh3»YÉ©$ÎgþN‚‡ïŸ~z@Î]–qQìÒB¸­/?%»ÆÀ,qV•»ÇyÙe±Ì°Ò;ï~xø½­jÓLÄi’ÃZI\V©ÏdZ³q4 ¾]Vß]î0üÕµ ls¥4(>Å6Þ.H^Ê¥-È S뇕‹p6ç¢úæÚHb×¾eoóû'{Î÷ÈU nŽn¬-J~HÁ±ù©;‹l ÙlKß¹¦i`T«` #g;Œƒ»´ÿ´DæçÍÕ—+fJ[ï*…¸sç?}ú†KCäêΣ3ÈÁ\Šk©oB#©(õFRw@)e ÎdhpÃ(§)S±:Y]ƒ³á]œ„ï?Ð w‡.C66çW+ü ÝZÎ×GÓ‡¿ ¤{“Þ¬(ÇnŽ“€ªé÷˜JýS‘—j[øðáã *wM¤õŠGW˜º‹½¸m•—Ñ?:¤¸¼Ûÿ A•ŠÒ€Bñ[Ú­ÈÞznéÂ#¬Øa.µ×Y1è~â> endobj 51 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [160.11 526.198 201.587 537.887] /Subtype/Link/A<> >> endobj 52 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [190.738 512.648 232.216 524.338] /Subtype/Link/A<> >> endobj 53 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [161.118 431.353 202.595 443.043] /Subtype/Link/A<> >> endobj 54 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [310.744 417.804 352.222 429.493] /Subtype/Link/A<> >> endobj 55 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [235.589 390.706 277.066 402.395] /Subtype/Link/A<> >> endobj 56 0 obj << /Type /Annot /Border[0 0 1]/H/I/C[0 1 1] /Rect [235.234 329.362 276.712 342.263] /Subtype/Link/A<> >> endobj 60 0 obj << /D [58 0 R /XYZ 125.798 687.123 null] >> endobj 57 0 obj << /Font << /F8 30 0 R /F30 42 0 R /F29 41 0 R >> /ProcSet [ /PDF /Text ] >> endobj 63 0 obj << /Length 1115 /Filter /FlateDecode >> stream xÚVéoÛ6ÿî¿BÈ€AB#™º,ÛÉ4׬KÖº€‡®0h‰¶ˆÉ”*J¶Œ!ÿû9–£´X?|ßñ{'‰ŒµŒŸH¯×³ÁðÞnàøÁÈ3f+ÃõB'šŒQè:^86f‰ñÉô-Û…ó&Ü[¶…æ®ÄE¤k’’[Ÿg¿ ïAr&hâ =Ȱ=ÐzJÃG^ã,Û[¶çy&VË’²„²µÚT¹X}3µ' åÕáô±Ì-ol6ZA¬p~ÊÕ¯ NÈ9A`®òR‘oŠŒ(t>:†ç#Ï £À”ðfx™0^ºFŽù-ë¹à0l?œ8ã`bخ:Ú¥40S0?öMžæu–(z Kdµ©RMp¼ÑTë5'ZˆŠXŒ½gþuFyjë¸9–€±{k˜Òc`ÀZ/•~+ËÔrM–Ø6Rx· ZDÌ&¾™3™!›+LAGËÍ›7¨ÈÓØLôÿkÔ2ÚÑqë认UEر7¾YX‰=”@4¸› ¾ \é14p1BÈAhdÄ›Á§ÏÈHà°;>ÔåN²n _ç$3> þT…ÜIZ€ ?nd„XQ¤ümš!/ãa!’´o'Žu6Á]¹“ntv))Áß÷Íù\¬¬6±—“Gùêä¨À±ðô+™xM†2ÅŽtôáiuŠæútG ÈphÙ!´ß¯,Îjy±YÑŒpMŠô "ÎÙ–”•èH¹_ÙA‚UåôÕÀôXëe!23¼9(>îã»&.œôê;¥¯1§ñ-®ð÷«xOâ¼L^‘5:'ÁYæ9¯Yì«4gp„½`¤ÌP³§EqàEšèéXóC”E9pH<929*ù‹>Ùs¬¨{Êà´ Bë:`?va›ÓD±ˆ½hš¿Qˆàsû‚w¤%èë-YQ¦ÍËÚ–8E-_(ú¬iÎEyÛ³#š‹©õñeZÛRnq9Ÿ_)Vá0sðâÿίÊ:®ò²/í­ì»:«h‘½âm~XÛYjM¤±þÎj•ÎR²WTŠ·-°üôOBW+˜7L—(«7K¢+WŒ±âr]o€ƒ÷šsËs¸(£ÕåU›ú×ÒßB|›è’ÑÕ÷¬+;ÄòÐHÇ©þU³¸¢9ëúÔÆF>¾›·ìàÚ©½öú<ŽF',¤:#c:—¤.X]YþJÞh^Ô~]Г‚?u Á†÷]„]jDÙ}ÝõttÔ7OO}ƒíúááÃlñø×ì—‡?ïn?þ~'ð¨qô­Qöçë=Yã°íŠãÞ†»‚ê°­JÞ—#1aE” 6§ÓR+\è‹sAà¦k{æ¢w2}U|)®º®ºŽŽ£k¾óDqG¡ãŠøðÀtõ%ìHÀëè?d&ö endstream endobj 62 0 obj << /Type /Page /Contents 63 0 R /Resources 61 0 R /MediaBox [0 0 612 792] /Parent 33 0 R >> endobj 64 0 obj << /D [62 0 R /XYZ 125.798 687.123 null] >> endobj 18 0 obj << /D [62 0 R /XYZ 125.798 662.217 null] >> endobj 61 0 obj << /Font << /F28 31 0 R /F8 30 0 R /F30 42 0 R >> /ProcSet [ /PDF /Text ] >> endobj 67 0 obj << /Length 1612 /Filter /FlateDecode >> stream xÚ­XYÛ6~ß_!äIFb®(’:¶E6hŠè…ìC€$0´2m ‘%G¢b»@ÿ{g8”m9ÜEÓôaW<†Ã9¿: ÖAüt¹ï÷7·¯DðˆåQ΃ûUÀEÊb%‚DqøfÁý2x–E_ÜÝíŽ]±»»ëôºêîeÛ|ÒYàî¢ÓeÛ-ßE*‚?þÍìýý/pÅœ ¦dN\nogs«ðç¦2UQWiš›ìÿ®jÖìò´òˆ€„‹ÃazÛœs&|rç߸uû*»TÇ1SÜqþãh6m3›‹L†þ8Tîi¶j;袜Åi¸¡ÙgYøa¦’°Xk\TaA{ï".k—Þüxóñ†Ãm`ß@ð T‰•e,ÎePnoÞ¾‚%l‚¦LäY°·¤Û@0)ÕÁë›?/Y€ÐIª¾œ…ÇË"Nç$N”;CTàä2gi”}•äJ°LðÿGrñ™dSÉÙîèñ3OÏPKó”§aß’£úÁ:qã¼çü¯·;ƒËÇkoBÈÈŒARL‚²ß´C½Z!‡Ùjš”.Œ¶;2,zZÜ#g]׌dAXÎrŒ ”9‹Á'–³`| IñkÛ!ÓT…e»ÝÕUé§._`ÈCÝõzÄÔh¥×íV›jk£[¥6bU¾|þœæ«¡)Me3feÑ4­!T-µªÁÄ]J <\ù²¦4õqVCK'ò|г¡×Dh“Ý^ß­‡¹&¶ºACáÝY¨h›…˜® Å3X^ïšÝ]ZtÚ'o£KÝ÷Eº‹Íæ2NâPùì"ÊpVàMÛ£Q4ͬAp·¬‹¾§¡Ó‡¨)~Ošâ¤‚@˜q²íh.TÚî5ÄwÔÆ®™^×+¬ÞãíRä8ý —-q…Ûzš6ÅÖqbâÅÄïZôYVCBw'ŸÚsÀ‚D&I8ôCQ£.GÚz@»}fÞA€Á}P(›*CÙµ¯Ì†VlÃwh dú’ò(ê ø@ÆúÎâ[tU¯1€†Ó*a½³øöÍ›ï¨Vaíy5è OîÍ'L’ k£ˆ§PC¬ ¿ãðQ<…ªO3ç\XuíöÒ¨½ÝŠ!8ÐY;йÖvxÎ' 3£P½{Ó ¥,ñ˜ûa„A0` .B’饟‡]hWŸ8Q,Ry yÌÀO‚œŠ)øOl ¸Ï@Cนpôp`ÿÊ©s.ÁBN=⌥~‚Ú nå—†YêÑ/X0 <…éõô1àË|'|¡#Ëx6ô·²'ò«p•ŒK1Ö¹ÃÁW %‹Aõh,ôˆ'ƒ£ öAþÁ@ž €[·!ö¹7¡îf9t‹ ¤M)ó˜A#‘Ûöà ñ©³sâ#ÆòŒ’ uMÛÒ‰}*c¨SY4´|ÆO……³2Ò‚ÚÆ4ey&¦îªšÏµ®Dþ3†œBeägÁXxAS¨Šü<Œý1åØuÚ ]CÄßW|‘ÃßS«üd¼©1Þ &¹à؆FÖ(vÅm]ÔŠîjk5 `Œ …ËŽŠÚ6aòTçìA·t†=˜8Ì· g÷,&yÐê1è·\a}[|˜h*OyUœžìËÄØ—Å®/{ Ùפ´ÅEèÇìÂP›jW-[]Ìlá„ú [4PlÇG[Øî± I'6K±1ÄeÅÑÚéY$AœÙ’©„ÏŽ^7ã{Ó+KÂï‰VŠí®ö6>Ö~ž\Ÿ÷A<D–Ž l_qh‰à1Îs8ù*lAJey¥¹ÃPS<Ô^/ˆ †É(Þ~S]ªW¢÷Z2|Q5Nièv›*ø©÷iÎg\d#o+‚G‚"9¿U<œRP$Ÿð)ÛzØ6n €Å™ÖË zpÅ’øê¹lÙvíÞÃÓÄS<x % +£;/ÅáJuù2ƒ¾_uKYvÆ~â Yî+ø4LãË2!eø»M ì‹zúvz¥»N»n‰"¾ìiì»e©OÛ¯zW/²êmrÕž~Pî7ìµúôÚÏÆñ‹].Û±‘›62ð~ƒFðâL!†eJ%ÈŸ÷ÛoÖ endstream endobj 66 0 obj << /Type /Page /Contents 67 0 R /Resources 65 0 R /MediaBox [0 0 612 792] /Parent 33 0 R >> endobj 68 0 obj << /D [66 0 R /XYZ 125.798 687.123 null] >> endobj 69 0 obj << /D [66 0 R /XYZ 125.798 559.28 null] >> endobj 70 0 obj << /D [66 0 R /XYZ 125.798 238.887 null] >> endobj 65 0 obj << /Font << /F30 42 0 R /F8 30 0 R /F28 31 0 R >> /ProcSet [ /PDF /Text ] >> endobj 73 0 obj << /Length 1382 /Filter /FlateDecode >> stream xÚµWKsÛ6¾ëWðHM"o‚¾5™¤“žÚ‰frp| %ØbK‘*AÙοï.dE›Ij+=á½ø°ûí<¹Mxòë‚Çöízñæƒt‰ÐLi+“õM"¤aYîk“Æ%ëmr™êåJÀBúû×n×ÔË•ÊLЊÔoÊ/\èMX^­{ódq–ó\ ,ž¬$H6’¤¼õ¡Üú°\i#Ó¢ŽmÛKéÒ¯4¼^®`àËz)Ò[š*ãÎw«¦Ýúö5ŒœL»ìð€+m=® ä£Hjnü=uöͰ2àÇíÏÂd6¾Ÿ€ …bÆæ2„£ WF­ÊòÓg Ë”ÕðVÉŒˆç@^öèÐD5Ô…•~÷Çzëʬ”JCW´]À¾N‹Žæ85_¸áwg¥µIÍ¡~°½­Ê°ƒ âûhWñj‚k_w½C} “úz‹›Þ-M‹êèiØ› Ö jÚ¢¾+UùZÛ[Ÿ\¢sÆ¥n¹üBò«^iͬ”þ2D0›êÊ»%Z”¦FuÙ\¨aÝ ë€M¾¹bVgdy“Ü}‚ºuúaéTzl»o‰Q¨ôÑ#ÐnȨ#ÐòpèYÜD+*Ô3tþ'PqØi=ámƒfPYá·ágx¾!ËÓcð7Ç üJ–º]œ½9Ö›®lz -Þ¯/œƒ%ÒYfœJŒ’LÛd³_\^ñd kà=LAð¸ïwîÅ´²Ð«’O‹?N%äœeÜ>[B¯¦¤‘¹fBË^”Œš]ûµ’q!Î@­ÀÑ…2/C=1…’ Þ裂wͱڒîc¤A±Ýú8[ÞQ”€>Êñ´.ö>Ò8ã̪G4nnˆW´XØ€tcÒ?ý¦‹d½+#QG£Sd‰³ÇHNÞï|\;´à<²ÃVQÏÈÿï,6g°XêKké±8;<(ÌÑØ€òe¢sˆß¹y]Δ3Ï1KdÉœ$8"¤¨|=Çd03:¸‚Œï„~!ð)—…ƒBALq¿žA ¥€³î,ÔÒ±<—?EÝ Xº)ì໲óûð™bÖ9ೌ)õs°;ŸÖN±c®+±Ž0P«Ýa:Æô5“@á¼pbp¢è3˜“ž<\ÅxÖuÀΗ…Ma2@iž/bæåÂb„#8VÇ—ß~Ëj’ ¦!Xœ^rà Jÿð’}m>?ší¦Òò´Ö’„Tòß$ƒ˜$°Û5Ôî‹Xjõ£²£6–&!”×U\êvE\,¨PÚÆSõŠRKî”ñ“ʱ˜—’ŠylûÐoûÐOÛ²…~õ•F}ñ—}£øS‚)®†‡vÅõ¦©.˹ò(‰jŒ;›vVœdÂÈGÒúÂú"tÍáK±9Ù#“v8øƒ¦4gÜœ›ÁjrXÈYÁcמd­~¥ÿÙàå TÍR<ÀÓ°5pµöÝŒÏùO5%ÏÒ_ÐÓc j :~þƒiýG—ÈžêI¡mQ?¹ˆ¾e@Xú½<±‡ R”õ âÁÇ‘ÌOooLLÝþšþ@ä‡ßPÄ›–úÝ®má÷sWC–j¼yS„ââï~ß¶C›&jüû©úÆKÊý¡ò{Oxøy6¶ï^½ê“ Áiâß ¯víô ýF·ž†¾þs®€¿+™e”&Ó@„ÿ P endstream endobj 72 0 obj << /Type /Page /Contents 73 0 R /Resources 71 0 R /MediaBox [0 0 612 792] /Parent 76 0 R >> endobj 74 0 obj << /D [72 0 R /XYZ 125.798 687.123 null] >> endobj 75 0 obj << /D [72 0 R /XYZ 125.798 662.217 null] >> endobj 71 0 obj << /Font << /F28 31 0 R /F8 30 0 R /F29 41 0 R /F30 42 0 R >> /ProcSet [ /PDF /Text ] >> endobj 77 0 obj [525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525] endobj 78 0 obj [500] endobj 79 0 obj [625 625 937.5 937.5 312.5 343.7 562.5 562.5 562.5 562.5 562.5 849.5 500 574.1 812.5 875 562.5 1018.5 1143.5 875 312.5 342.6 581 937.5 562.5 937.5 875 312.5 437.5 437.5 562.5 875 312.5 375 312.5 562.5 562.5 562.5 562.5 562.5 562.5 562.5 562.5 562.5 562.5 562.5 312.5 312.5 342.6 875 531.2 531.2 875 849.5 799.8 812.5 862.3 738.4 707.2 884.3 879.6 419 581 880.8 675.9 1067.1 879.6 844.9 768.5 844.9 839.1 625 782.4 864.6 849.5 1162 849.5 849.5 687.5 312.5 581 312.5 562.5 312.5 312.5 546.9 625 500 625 513.3 343.7 562.5 625 312.5 343.7 593.7 312.5 937.5 625 562.5 625 593.7 459.5 443.8 437.5 625 593.7 812.5 593.7 593.7] endobj 80 0 obj [583.3 555.6 555.6 833.3 833.3 277.8 305.6 500 500 500 500 500 750 444.4 500 722.2 777.8 500 902.8 1013.9 777.8 277.8 277.8 500 833.3 500 833.3 777.8 277.8 388.9 388.9 500 777.8 277.8 333.3 277.8 500 500 500 500 500 500 500 500 500 500 500 277.8 277.8 277.8 777.8 472.2 472.2 777.8 750 708.3 722.2 763.9 680.6 652.8 784.7 750 361.1 513.9 777.8 625 916.7 750 777.8 680.6 777.8 736.1 555.6 722.2 750 750 1027.8 750 750 611.1 277.8 500 277.8 500 277.8 277.8 500 555.6 444.4 555.6 444.4 305.6 500 555.6 277.8 305.6 527.8 277.8 833.3 555.6 500 555.6 527.8 391.7 394.4 388.9 555.6 527.8 722.2 527.8 527.8 444.4] endobj 81 0 obj [869.4 818.1 830.6 881.9 755.6 723.6 904.2 900 436.1 594.4 901.4 691.7 1091.7 900 863.9 786.1 863.9 862.5 638.9 800 884.7 869.4 1188.9 869.4 869.4 702.8 319.4 602.8 319.4 575 319.4 319.4 559 638.9 511.1 638.9 527.1 351.4 575 638.9 319.4 351.4 606.9 319.4 958.3 638.9 575 638.9 606.9 473.6 453.6 447.2 638.9 606.9 830.6 606.9 606.9 511.1 575] endobj 82 0 obj [272 326.4 272 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 272 272 272 761.6 462.4 462.4 761.6 734 693.4 707.2 747.8 666.2 639 768.3 734 353.2 503 761.2 611.8 897.2 734 761.6 666.2 761.6 720.6 544 707.2 734 734 1006 734 734 598.4 272 489.6 272 489.6 272 272 489.6 544 435.2 544 435.2 299.2 489.6 544 272 299.2 516.8 272 816 544 489.6 544 516.8 380.8 386.2 380.8 544 516.8 707.2] endobj 83 0 obj [458.6 458.6 458.6 458.6 458.6 458.6 458.6 458.6 249.6 249.6 249.6 719.8 432.5 432.5 719.8 693.3 654.3 667.6 706.6 628.2 602.1 726.3 693.3 327.6 471.5 719.4 576 850 693.3 719.8 628.2 719.8 680.5 510.9 667.6 693.3 693.3 954.5 693.3 693.3 563.1 249.6 458.6 249.6 458.6 249.6 249.6 458.6 510.9 406.4 510.9 406.4 275.8 458.6 510.9 249.6 275.8 484.7 249.6 772.1 510.9 458.6 510.9 484.7 354.1 359.4 354.1 510.9 484.7 667.6 484.7 484.7] endobj 84 0 obj << /Length1 849 /Length2 2847 /Length3 0 /Length 3426 /Filter /FlateDecode >> stream xÚ­Rw\“ÉéÑEE% (‚”„Ы”„&ADªhH> šIDé"MDi®4P¤ÄH‘&HQ¢Ò‹4‘&åEöíÛ÷vÿ}¿™?æÜ{æÞ3玬4Ú^ÙGöÍÈ$š2†ÐÖ&NSQ1ÈÊ") ††'“P¨ ttT3Ѓsàl] u]Mˆ,€$û0(x/o <ú‹¤A ‹!Öš7HäÔÀb€=‹i `L 'Ý 'A*H¡ƒ8px, ð½ð$ü—&K’'Ðú#Œóóù3E)TŽ(@~KæQ€#G&ô„ÀmÈœn GËÿCÖß‹›ù6â¯ò[Ný#!â Œ3ÈD?H¬É8Bú;ÕüCœ ™ð6–4 5&y@@åžj†qh< ë xbTp+’p—À1nKÜÙâÔ ;{ÅÏt+‰ÆàI´S Ÿÿ”ýÅÞˆ¿0Ç >pUáØ‹à9ëÏÓ™¿53%aÉ8<É PÕÐ0 †áüÒ.!< `G1F"Ó8WŽ%€'™ù5PM nü+´…8‚cþBÚÜã/¤À±ÿAU5Îy:†êýW ¡À)ÿ9µ©ÿ58m þÓ.rÀ%e5ΕU5T~qÕuÍÀÿabý(DÛúŒœÖbOn¯7lJ˜UÛÃÞßä&­Ùvùø)-£÷Ô¶ØáTÓn³ÄßC­ÛñŠÖ5Rbµ­Sj…QëÕK¼;wí¯´wt—CŒ.ù2Ô }]^ëÑd¼o42iÕ‡¼~·xúH‘ZÛRqè™ZÔª‡Ð¹8:öbÿ=꤮¼‡Á’ËÖk¤íªd°SðüäãjŸè”jk‚´Vv¥…tÎ|í®šå§¡ëåè83êz¯Hü<Æ?G.ôÍOÁs2·Œêu›ÏfÚ·Mвª3YîÎY+„œ¬çÍ%5<;ˆÅ~œ™goÜDÌ¢D©‰ jÇö‡œžH˜9±ÏË„>•¢ãw&.T¢wyõI´ +ìÀR‚X}שG¸kñãË*ýgÕ(e —ͬçîá J*ù<¿Î»_™³(nÍ,ßñ< e´€ku<ê(ŸmìŒm2±®Õ c¢MîÂÁW ø0äK"çU:/GŒ&¹­Gò˜Î“jàrÛú5”i(E€qÿYâîJ¹/üT\ZhÎëœÀ:^¨øîuø£´«è_õ D¶yº¾\ßÑMÓð±4Ž^PÕº±s©ãø‚¤ÃââO¸<;JýŽù3 ;ý 0XùwWù™HB k÷j957_*v[ûG )™U|÷"ª¶ÿڇϲر¦†¦,„tz#%ðŒù%YP¥ËRath°9W=V±‚t¯a‡¤åNK‘½ôœÑlŸÁÊYa ²~8LGÍôrM÷î§ÚB‰eÝ  YO2µçâ^¦óÈ£{yr1Y!=>‹s\Ä Àû¬ûQ­FWtûe¬X>3ß;èdÉúÖŒ»1my„ռں鰚$²OhwcÕЕúqcÉžf’VudŒdÃŒÝæŠ.® T]H­å³ò“ ½‹{f42Ue…ëw¥@+'½W½Z%5°5HNµ¯éíQ$woÚ S6yÏ'”¯Ã¶ŸÅ.>C«äOW¢&ˆ·ûR¢ùòÌ·YòÈîß|“¦Ñæ;!3es0ÏÊ €õg’ éþóólͯ·ù.3…_ FÒÅ7Îô.5O¦§Ý„rÕ{=1Ô-ìa£uÛ3Ö%äXÁè®yÜ|;)ÕpÙjáÀ'}Ûê^–n'Z<š3îlšr™8 ?V™F ɹ£_¨qþ㎿âpbZý<¯Û€ÌQ¹¾ÏÑS¶ÈÚYýGÕÇ7¿dÖ¾m1‘Ic[…Œ*.hDZhâžeû çôqâ°ßui@J3 ½bNÜUȬ<ž iÚÕ3˜A`î,=´ÞÖ‚zâkïdÅ>Fœû Nm¨ÄývQ£"CNº$yÓ-ñB´øó¹ËêáU—ÚvvĪ=ŸŠ©Žz§0¦wŸ?ZäôÞ^~«¢#²‰‡Ë,Ëܧ,Û "Fbwì`Ù!u·'ÞDlocÅ€ÃöÒÖ¸%+¾œ¸ÙÔÎBµ¶"O ÛAO+(°ƒ/´ì©ûîÂ(¾®JÚ³<¯ñí ãmRfJÂë1±É…†ó©©ž¼•ê9j×Ã[ãJ 6]–< e\8wTÚŒ@ÓãAʸ¾ŸþšpLéðd?KNе6<Û·DèéòF>º©õH¬Ëüo‚=àÜGò‰·K~úBŽ]l¥/åø'e;Púºk2Û62<¡¾”p¯^dG¿L[À«»‚„‘/ŠVVü‡60=ÈÚÝIhÙh?¶yKJW¸Û®+uâ÷c÷ÉÞ•gFŽ+zõž%(µðûú˜Jï©LAÀ[Qªbõ¬ÂÊžþAKㄆO„kÜÞ•[¯ò´— Sd­Ê8õ".7˵E«Ç]Z´Ýþþ k´úHƒe—7¹Uw•ØR«Íj >®Ž®œÎ|tImþ˜g×Õ­”ÜyS¼.}U†{}8û5aNÿ]RU;+ @%|æZxØ Ÿ¦fü ®¦Ñ endstream endobj 85 0 obj << /Type /FontDescriptor /FontName /YHTLQS+CMBX10 /Flags 4 /FontBBox [-301 -250 1164 946] /Ascent 694 /CapHeight 686 /Descent -194 /ItalicAngle 0 /StemV 114 /XHeight 444 /CharSet (/A/a/b/c/endash/r/s/t) /FontFile 84 0 R >> endobj 86 0 obj << /Length1 1224 /Length2 5703 /Length3 0 /Length 6438 /Filter /FlateDecode >> stream xÚ­–eX”ÝÖ€i¤¤‡–fèNI)é–`p˜¡‘n)Aº»†.¥¤EFBº‘Tâ‰o|Ïw^ýÎùû]ógî½×^ëÞëYÏ\ÃÁ¢oȯ䳩Á ^ü@ 4@EGÙ ( ásp¨ÀAv^`ô¡H”’”¼ÂB ¸´ˆ¨´˜(>@æî;»x¨pÿ ’(¹à`;(@ÇÎËä†Êá`ÂÀ /€0øuÂ`òÁ}@Žø@ Àìà°9ƒ¡ø‚¿Œ4¡N0€Ä¿–½Ýÿ½å‚{¢¤P’Ü”¢# ñ8‚œðua¨Z ”Éÿ‡Ô&Wó†@tíÜ~¥ÿ»Kÿµoç†øÿoÌÍÝÛ èÀAp膚‚þ%§ ƒüWM/;ØA ê „þµöTûõÁ^.';ˆ'èïuÔñ?Pmû[@PI[ý±¶.ïÿ>Ï¿7õíÀP/#÷ÒþŠþ›¿Õ8Ø`)$ $D¢>ÿþfýÅT¡0G05bâ;8ÜÎ5(<ÀPGä‡2€Â¼PG¨–œ`pü_S\ eùké_$Tù‡$D‚š¿ µ§óI õÿ!Ô“´ûM’Aûß$tø‡€B¨ƒŽ  ú…‚N¿ñÿA±_ó†ÿŽ2tþE‚. ênà?¥ùQ^n¿ˆò‚þ(/Ø?(ŠŠ…Aÿðüeæþ{[E¨Á†ýq1 ÊåS ÊÅó÷T¿žPû摜5{»ëc»›ÐIov–£ã¿ãÎzqHòºmæ¯#1t=äêxušyÙPþÉða±þƒ‡FŸq—YÐú-}Zús#Å%ÌÔr Æ1QMœ",¤YÕ±¢1+¾¤i/±V&#‚]cîuð.ÂÞx“_•Þ+J½}‚é8ab{ùèK†?Ñ–ÅUòûKòÆP몸-ï"ló¤ºk{Ëeæ< %ä,!w†ëœÏË*»¾Ç}±~¦ Ìâ‡Þ=ZQ„ús- "p\Ww‹1Zcò+ÎÉö•’7.¶ºLïKç\©ßµÆÈ¯·|$Nêêd²9ï¿zËÍ~§%ò(jáÅ\”êM]KH6“gr#ñž«Zù«X§>RV}öÙh~ÍÕÖOGãé ÊCøâr.eÉMHOd·lñTÉâžö5#TSIuQ/üp‚–úw¼ù`í³gâam絚Iªâô?Ö™_s}ÛzïO$éüHž“&)LoelÍnf÷ü3?Щth^±¹¦‘kR™èöÃ4F®Hûd‰£RÌ«lU@ßZ7‰@Çh2D”Ž~IžÓ·?ÍG·Îl(ꯂÓ{*·$…k h‰ND;¹ó%Uðì7À§ù0RúN“-•âÜÔÑŒ`ºmB!‚[3§“¹E›!:öí¸_K9fBÔ%÷sGIìÎjë® j{BQÖβûqí/ž„†”pÖ˜ž<“Ò Ü"þØ~H$$6D™Xµp%ª!JySµµ\Q/ÿ’CVd2vïI™ÝtÞ¾øºy0Rùj<9û^ßÏŸ“áÍÎð ­ÎìêB•<3›ÞÝ)œ5“â:ЩÉáíÊÄ`œl¯r'TÒLž;Û×Í…2q´mÌà™´×‡ ¯~qd†ÌÉ ÖHìåt'¶k‘’¢o•*”_³¶{àK>‡+ø ù- Ìüì7»Ñ‚ûöXÆ|áĪm]'B1ÊõÜ´94äw“òޤ‡å‡CÒc°Š°Ùå†Ó5Þ!žx¿ ¿k–ˆµéhfˆåÊ<© ¤R·Ò™ §æ? vêí{:Gl[D©Ÿr¿±‘À¼aîç6õ·@ÁR ?‰˜§º½;>•o šÕ®K‚êöÓù‚EÏ ¾µôŸ0¹#Äa£Zíª[%n´@†Vƒµ¬bðüè•å“k D›»}®o÷9Óˆ¹Æ3WDLŒ¥˜C·À;´ëeM¾£d‰zûYY6‰Íe¼lÇg8íõ8•zp,¥ÐµrSâdóÆ((m®âA«°b2¦Õ‚œŠ‡„8ãÆ ×uL8+Ë!ûLe†ÙVv;& 1ØJÞŨGÆ4C¥wšîÔ¶ê¶xVn¿_³L#»*ŒdÄ_ ÝØöx†¼Š<£(—I­ÛF×ˆÏ ðIžÜ_+ìÎ]{Ü…µ²†V Úùê·š1@ê2…”ÆðÁå‚©¹r@ú"‘iÎï^0Œúi)¨ü(ʯ^pMÆo§é0ÛÚSÜtFöÍvj@è3‘™úäǸ¬hÝŸ+ú¾ml«Û$Ñùê{$šD<¹ ,Ñ3{$Œ‰y $¨òPeAã5æÙ0 !ÐÉ9å~¹’-3DßûDòmï äåÃ[›Ã5zª¢ÀoÏãÞIoTe5|io:ðÓ§• ÌJ¥«éú‚0Бì#¹ÖëO]¤—\ÔÜc€·fF¥¸Iál÷·ùT÷rà…W’ëbl¼èJÁQ>#ï1j˜9s:Ü,ª~j 6H2ê$V%[E~~¦7—8žÆÛÙMŸ}G½|Óy¿Ê a¤¥˜ÿ–" {Þt¡w¶µê4·C€ñ¼–Å÷4ˆRعøxJÆx3B­`è\ÏSh1†>ô¾èÜeÆA\áH}pˆF(µI§E¬Œô3t*×}¶Ž‹ƒ’ˆ Ã]ƒŠ»Õ÷b%4 %°Õ11›Ùö©Ñ¬÷Ó'¨x)󊌶°“©Í qBL ÖßC,ƒn*X†"S„z·õ0ð‚º±o¬ÂLžÓaÉ|7lBhãÌÃÏné'Oà»JEš¯l+컆™ºzknqFr£-:¸¾6ltJ»Ð·­Ú»ÔÆ8ìÊzåN{:¡·‡ìpJ!&9]|ßž®k&›¥8_‚œÚ®¡µ<Îö!]ûFࢭ›wZäݽûø}¼dëds¥Ü†?QçÆ¬nâ“Ð'-õæÙÆÛYšUÎÞ€y :Ë·w2悃ýy÷ÖGxpC ’ îˆ$H¡[ý™aÎíê{-(q†ØC›ä )k«´ŸvºòÕĦ#¦‰ÚåqÔÚÙV®ÓÍ1Û’î[‹\-ä›ÈyÈÍG„Õå8yÇÚ¨žØŒf=bõ¨f.(þ¹?U’f`¡YORJNý.­YœÓ“7l¯{!ìS¼\©•‘Woöð Wbêù2%¹»ª«:kÏÝ'&ãU‹Qí/)“]ÏüÛ¯d4ÄLôÍ÷ÃÑgNRεSð;Wïâ'4ŠÁ§É Ó ë2g¼ÍËÌ®ÊwDÖ§pïiöŠHo9Š‚JÍM—ç¥?žÏŽ~{•%5ìfíºŒPJ#6ý«ò-_ÿU9 Uoûå:«±©ÊГàúû§ùx>x)=:übtf=†ÎåA ½HQýôý½‹dÐè–ÅŸÄ_ú*¹^ 9ëÿÀ¯˜p[ýYƒdßUÌ×ð?êér‘¨I ÒàîËÖµz‘sMúþ¢ÝýŠPÉL€¥³~ÆÉ2ë¡"2va6[˜i‚shuŠ~ر]sMB‡j8ÍÈk|^ Ó>Ϙ¥ó!‚HŽÉד\Ÿm¡A^¶…Â\.4Ä'øêëHn…“Õ‰€{̩зc<û4'ßö¿Ù¼w=•kt½ô4†É«ñÕÔL?Áî {Og'ž+I£¯  ¤Ç¼MÕY6bè23lI¥@2jn«”ßi)Q0 vŠŒ_’Ç(>½¯õÄí!j"²Ï°×]Ÿázcœ¾tÏíΧYATžºQìœÏ0lvW)yGû{±OëaÛ¸~ˆÍí<Åê_l”¼ð6'™#ÆJˆŒÔI¹W„%ª°ÌÂRø¨ÑLùíÛÿAbZÛêÍ3¥ÃçÏ'l »èC¼º”q(ÔÄðûè¨@~µ7Üðáj]\ú© ?lÑÊ.Ž¿¼”™[’Xm ªž2åé£Ì`Ñ“VsY•wì¾J¯ÙN+^OÍ´¾» ‰Ò¡N›Ü8)/]æqÎí¸åOU3Û¯ÚšarÈí~´g¤ó ÕŒU¾°5»9O£ZƒÍþÈÌnÝ' ÃŒ³ŽT­?gÏú’äLÓÔ?ßsÕ*@z¦`9}¸Y[§zÖž1s+mKxL¯›Üµ™U~#fœ‰AÞäÖ‹èœ×¸e¤Ž¼Y^{h2=pšg*EÒP,ü²6þÚìì1Ì-[õøûw"’¾ú/ŽÄÐMy[Ö˜»#¡JÇã~À!òlßõˆ‰hk|"›jV«Fµí“ Ü3EüÍ B¾Ú’ 6ʃž£ ‚fN¯ÐÄ[•j™t [RºÃDSg-Lþ.’×EèÏàÉ x‰h×£X;Ã_>ád˜ír'åi'T<£ f¼™|Î9AŒíLŒ}蘾mË_ijÐC7D¹fK nš’øø=öR´ÏXpïcµl¹,’¦—|šÕÌ욨³0@òhfR<ð¼SmÄ–£…¦Ž4çrd}S!»·˜”LÜLpÜ9ÒùѬ’÷öÕ˜HìqÉ&–¬VÍ ºÿìкší'ƒ°a0®ŸŠ½¬`=]ÖåæÖΩWrõ8ËóŠ¢W8÷9[8EOç_0bŸ È™“§<ø!ãñø€Íš#WEm—–5qŠšÈ;CÝžY‹“->£>KŽ¥ùÕ _0qH3éé’°oÙ—g0{Þü¸…Fð4€ ?‘‘ãr,Nœ»¸¾‚þA=ÒíX¡Y·kð„J1ÓuÇî÷Ø#œ,î,ĸÝÖÌ"a}ß`I:•^“Xå6ð5…'£v3ÚXv‘òŽ9kí×IJc~#}­êf'qìŠ@÷±œBô™Ô±a¾°ÂLõæ)Ílõ ¢ªäüLéV¸ùIµ²¨Ÿ {’`IÇÊó51¸v¨H|7?˜þ[Ðø‡#ÝôòQ>W®€¬rìâbYÚÝÍ_¬ÂgTQû‚5W,¹›Xô#Ö©J°²g¿¾LÚËžS)òÀÚôæãÆ-ðœ;0Íé`œfª¢= {é*® b{ø^Öߥý(íÝUæýl@14}=¨0›=OU« Xò³Ÿ‹™r:ì0’÷íTü§/Ƹ˜÷¼ž¨Ïy?£¥Tìèg é^æMb}7’ø*E*þ ½Ó¼ºŒz|Œ çÆ²rIz—H9Ѝá¶ZªžoÅÎû>z¤„ôK²^Y¢þ²BX.þ¶áeóþIÏ5»ÅkÆöžž·a;/ºß‘.^ɈžhgE¾”pÀÁ ÄëF¤n<E=6Üü×§K6Îàï†JsäcÚQj™&¾M¥guÕ£E/’¨³óêÀ5¬¸;í‰Vò(ex^qöàÑŠv±mŸ…ÎD/ew[ãÒ/ψoû›"%̃-ÿÁ\ü’í>¢7M —¥1±ùgjÕ™ïCÕ~(Þk©ôBÛ:kôô¸3Ö©õª¼9eà§?Ç#3à“Fº×'gz™HW ‹5Ù ¸ÝŽÚ8í@ôãÓ;²ðà#±ƒ¾Q½ÂÒLÛ ÂËtaù¦rö=˜¢£A‘|5 c²wœ’sÅò8ê'uþä~óºóy"}1þcÝè0ù-ûvÓTh;ÜÄrðô;Cœ[¶‹eUËy¦”áÀ§ø0>y©ûVˆ‡fdߤ]ŒZÙvÇSòGu3±öO> Ÿø`µ¶;oìù)½r·‚É(IÛvø}ëÛ†{KC,õÆã…ÕMÏhó9ÍUÇ®,»@e93¡ýá™ELƒêa˜FÅɼ‚·×Ý™€ÃœVÔŸX«dƽM’x€dk%-<¬}¬ù›ùÜh¾ít¬ã<=§ÏŠß©þe‚¢cT9ÄÅ&ˆaü(;]ø¦-‹á‹Î ?c—â.{~Š|2eñ¸”šk·èEö@çwyõ’²á°Á”{óh×Çw_s@õ|i 6E;+_‘y) ·älÇgPÑ`vlHÓ^± :°‡­ý]kåÕ E¥üúð¸èegзF:òªZzu¹Úl/Í ®g[ð°Ã—{ó”/.Ïó‚í+¾ÒO¬ÝorÅ)¼‘¼‡>¦Kqx$ë¦sy#yè²fæv²1âšI©ÍM¼‡ ©ÿrWÚd‰¹d’.­S p°¦Þ 4p1¿£ç “è=Y[”‹XQi]4XRrî@[I¹«)e¤¬«å˜ DНkà(U¨Þ\wçàíeà¡¡»%¼·Á©Âùp4UrEŸÈùs(´+²Š;27^èÛÈËv=YŽhžiò¹ÔÈÊl÷†Yeï¹¼ìe\wqiÚˆ ·¢ytonDF½äö“ú×Ãaw·G*韚0Y·@¾ós2fBUæµ0¬a¡d"Þþ,/­í§­ Z‘NHzî½²ãêX‹ô™úûÂ3ç’"e^¦l¶L¥Rd5C~é_lÅÕÈl]FTNN0ì•h§Í¤Æ}zË*É©Éñ9¢ÑfÀ6+Î-ª¼¼;÷m—¶ë´Ðæÿ\Ζ·»ºÃl—©¯p,7ÛžãÓ~¼§Æ,)’Yç…¯ 8am|‹YY§LõMÈxòg1 ‡¹gƒ$}8¶%ÓéÁÄ`œI«úT”¨»”©Ô %ϘÎô8õ3ë‰÷ ¢$ÆÇ@ðb›îIõSôTв:ÅÚŒ™½#ÑBé1¡e‘ዜµkð›âlaó°ºËJaì€ïÐxÙض'¬é|Ô=ö…ÐLrˆïºsy’âÝN6-&ížØX FÂ[o†§¬¤p4³2 »u[ÆEÞ…ˆ@ø=@ƒn@óüIRÞ7ÜPÄͺÉÁ»¶ÑzâÝ%Î[çˆ'×M¸xjƒã‘¶–EÖ3Mº¹a+Ãðì„©]ê+'ô›ÐÓÌòùc̪¼Äó9©È=3à¢wUÅbY_CÛƒk~ÁÝš'‚ÇX< ¯~Žáô¼rгœqEk¬~™e—•ç¹¾)zTîÞ)CÚqÞ}ø‚ï Vtfôùp{küë¸fÃÌ-âbY—Ý·+Î> endobj 88 0 obj << /Length1 1792 /Length2 13191 /Length3 0 /Length 14176 /Filter /FlateDecode >> stream xÚ­—eT\ݲ®qwHph,¸»»»;¤ÆÝÝ݃{‚[pwÁÝ%¸[p¹|{Ÿ³“»ïß;ºGõTÕ¬z«æZs¦ QR¥6±3IØÙ:Ó330óDåU˜™Ì LL"¢Ž  ³…­ÐÄ`ææfH€ŒÞ/Þ¿<ìl<ì,Q;{G 3sg•(õ?Aœa£…1Ð t6Ù¼ç0ZTíŒ-@Î akk€Ê?+œ* '£+È„™`baì 0™YØ"0þ#IÚÖÔÀùo³‰‹ýÿº\AŽNï¢Tÿ’I xibgkí0™"0*ؽW½kùÿ!ë¿“K¸X[+mþIÿÏ þ7ÐÆÂÚãìlì]œAŽy;£í‡j‚þ­Mdbábóß^ig µ…±°­™5Àôo“…“„…;ÈDÉÂÙØ` ´vý˲5ùoï“û—F) q9)-Úïé¿|J@ [g5ûÿdý'ø_Ìü‡ß§ãháÐez/ó{àûç¯ôÿ«–¸­±‰…­€…ttz ¼ß=ïÄðbXØš€Ü ÷wÁŒ ¶vÎïKï3ñ˜Ú9"ü³¡ìFáLÿ&£Èâ0Šþ!.£Øâ0Šÿ‡8™ŒˆÀ(ù‡XÞÇð‡XŒÒ轺ìz¯.÷‡Þ«Ëÿ¡÷ê 轺âˆë½ºÒz¯®ü‡Þ««ü¡÷ꪈ À¨ö‡Þµ¨ÿ¡w-è]‹æz×¢õz¿«èÝgô‡Þuÿ‡Øß}ÆvÖïÏÍÿZØØþ±ØØüYÏÌôÞŒÉ_øÞ è/|oÇô¾;Mÿœʱþƒ®­þÇ`ýÇÿO¸‹ã_ÙßÌþÂwuæ´¾ÏÇÜÃÞdûWÄ»Íâ/|šå_ø>«¿ð½}ë¿ð}66µòÞ÷_™ÿiÍîOí÷X;Û¿:ù§Uû?î÷µö@G­5ÈÔù•ù¬ÿ>ƒþc~iÿ~ Ùý™2Û{ßöÖ.Nå·8ü…ï“økNÌïmÿ fç²±ø¿·–ýŸë_ÓbOâôþTÿ§êûxœ¬Næ%~×öG)û{ÎæŽ ?}³¿7êìf÷ׂ÷.áûˆ]ÿÂwenÝï«ÝÿÂ÷ôáûH=ÿˆ{Ïä rüw©ÿ÷t±s÷¢gyWøþÃôÏ]Ë àæàöù¿"]ß§ïü¯—Çû!ù¿ljñ~¤‚@î c„¥y;cÞ`ËÔÆÐR_ñüÉ2hp³¦x…ºî™Ä Å/àÖE#²4ëµZå˜({Ð{ÄnÏøN‘íÞÊcçñis¯{®Ÿ÷2<[ðµ®2ä=víIQÛgoNØÁ§×GK“´ ú³/Žs•¨ÄÔöaWIÀzt]ë{2ƒ98µ$2¬ÕÃBj?±’¨ ¥9”†³…­¹¡%%@­MùZ†Á5Ó®\Úµ»`<æÃ}K|Õ»û‡nÜN̪²Mƒ¥²/xRR††ZóÖ7T%” 0SuìA/éŒHå`†Ve{â‰N]`‹‡Ë»žÓµ´k‘¼Ppè¯í²ÒšÈ,2]$äÛ}¡|€ó|=¤ÜsçµË&ú‘oúŸ{£&:çÆhèQë@“ ·X’aëôgdNby2£Üd©ã û"Ú &½y¹eè û9!XüB{´¡~öU4BDíàS:ÌÁÎi ’“íSÁvd$ŠºÜ‰õ`¨ÚÔÓQš‰VA—ž–Wƒðî¢ÀXC·ƒ2^R)®PmÎó Ø Hrg7Å—þ ˜›ƒ@ŠäTu`âß«„)AQGÁ†quÝk«§É ÿÞ.P=âåÉûZ¢xÊýóÉFM·¶½/Çàcª lyv’ºõìù¹f¦9Xã*OU0¢à@ •#G,¯ˆóÌGUœ±D¾è ãOrF^:Ùð‡Üb¹Œ¤S°ÄÂ'æÍ¦ šdÕ í$¼¹Ò53e7àKZyC׊%é%¿ÁE‡«a?•¦¼‡ æ^úó=N¶CóÊM²RëQÖe‹w×àÏéØŸ‰QxØhö ŸC²"í•0M,/,)'ªý_½>8áµÁñ¢àâH›íÎŽÀv¢ÇŒÃ¯ŸyÏ—úÀÀuA¨Œª6ŸjÞ,XsƒlŒõ˜º­NE)ì©w[µ˜Z"…È{Y,§¯%$¹ëÃ)*LÓ聆ädNÄ„ºlÊÀÒ×_XŒØSôŒM¬©µ2­»‹™c]E‰ yX~6\¹Áþ¤F¹yÙ„Ã6ÝeûØû³Yàºv+X¸U|w²ûnQØŒ©Jvç9‘(E=i“CY‘¨Ïj¼cù‰e³„”Lë¨û–Áê‘ï«D˜Aýp:Iæ—=,Oé"s% 3H¤ ¶dsZî[¬²3ó%×ó±Q( od'Š<"é1f öoõŽSoq~í.Öu‰àÀÄRwþÉ߈þV…ç0ðöQK=oÅ9 üÖ·ãšf™¾Ù)€^tq•Áƒeøyu–SªAý³è)D¿€êqѯ oå£FLýÌigü¹ÔjÄÒn¬e±§UÀñ>›×ψUR‰ô}nÇÚK¼õMöæ„ÜÛ¬h¼€ñ>.¹+@d <¹þîsbxí:éN°ž±öT¨‡Î¡Á/¿A“xâ´F«i=åÞn'ü‹§=7J¦ÌõYýýDWjÉ¡§}Fê*ùr€Xü:˜—êÆ;¹zr8büR‘þëÊõ¨Üi³’µ³Š¯ÐÔâ·8iu2ŒÃ'!¤ pæ‰É–<{_V~g,AìçÐçs3а‰ê \±oq¹ù]Žìçf‰þšLub³ö:èûa±æ¡ñ´ýëì9†j궇W@yø.üæ×o›šsRå±Ú;”7ÂóÔ.èa> +Uäyy½ŠdÑüŠÎ³ÁÊeå‰ä*?ŸÕ«pc]å[WÏ.¨t"8“ryå‚åŒâõ½W,²!'æbFæ«L±Ó“±¾6ÄgJ—ãÃè´ý=©äk¸·¬r…Ý/Ö“fM$(¢o&üù·Ø«ŽÚ\j²š¥;tM@Cây£åMäú–±½þ!cÙ~E¼¯PÒûw¯ÞÊiSHPI#½ Cûý<¾¾Ä§%äæOünב塎p‹\n{D ÆÛI=`Ï,[Jæ´ û4«RgÛy­gß;é1î¸B¯…•Ô,Ë¡H&˜I¢PÞZÍDF†´ùík‡‚Þ0M±é¢vŠç®uКUM­[âXƒöpöK¡~³Ø–ÉáT–}­ûÁS‡Á4>7œ†Þ‘Äsþ¨[PÚ£aE—{7Á‚ŠámÓŸžT†Ÿhqµ~­³YWÎù +¨ï#JwT(c4÷…<*aø°=´FÈäým@%¶&r)?Lr^Æz=“¼Ý Zƒ.‹ dö±¡Ž¨ˆ ³Ãäòlü_Õ*à~ËxYvd']B®±Ó»åU›Ä„¾ “±RÓ2â0ãV~‡´í)¥Ýf»æýiX;Iv¶¹@íç£È­…¶kÑîBÝ lñU$âÕW÷q–=¡ÈõØŸ«[@iKõ£k‹•Â. ©Üo!_³˜é"ùñw|õ£ÛVò|Ô0%jYÈòôÎ/j\yæfÒ /¤²;s4`nÛCe¥kî9ŒM9’Fýeò&8œUMøîö ¬ V˜ ”~ËôûJ™¤ñü‹]>;s•ç/÷¤HâAÞœ'nÌ?ì…ž´FuûU6Ú*TÛø&¥6`?˜õ@Í"ÞÄün..rØé¹ êéxºgÝÓͦë"ø\·ûƒÒõ9‡Hˆ‹AB(‰ñëkÈ„ló¹YÍjiUúR¤%àŠ< =³‹w€^éE%j]¤ŽÓ–œU9ý1;Áœrü°·‚5PWGF¸\؃Ò»ªXJ·Ý?½8i %ìgÅ0ƒ¸L)Û×ý¬Ímˆ²kÅr]âœ}nX™sf÷èßÒ“~²vRB@§lvϬuqAÌò:ÕÒÓûÔjœBÍ6”‘Úyþ ‘°áØ(ìì«=^ª<=°aÃLŸ‘õ ¬Pí>ÿŒUdúNÉuyÛyÞ‘Ó¾’ßd‘DUŸÑâ¶Hz¶ÁÕð9ÆÐ[IÉöºÏjÊ_Á?5u?Üg“á‡\óI‹~™ ×(›ÏYÒ€éçõìí÷Α*?S,•Уºð öiùTÚ–S¿†šM<{i]4¬Í~l!?ÎJü™ÍÕF^±Øð€~J¿A®AÉV#MkYKo_Ä`J°µ†bîj–øòË#…"1¸@ãcøéÅ[p¼º-&D–¼Ê.ÛrÈ+“0cZ6Ö¸=˜Œq0á†I4nCmí{îR%sÀðíSòÀ·.âNWo:´[´íœ©¤X~"‘q÷±qê#æJ‹7ño0zÇKNþtCÐÔnN‹ª’âsM2•IuøXƒŸL«éTÝMnR® e%×7Jã…“ÉÃÆGc,sÖr¡ä•ѧ6(mã Gq”€Rå{þÐ’ÃlJ¹‡õ6ˆ!WTÝÄiîþÑFh»x@ OŽ—Õ;…U2ÃËÝ£.mB²ª31V¢Öù`K*†¶4z “¾AMh7ì÷[m>¼¾©'Cب6žœôv³ËëK_ÁŠÕr¹°…_$•fü¨·^%ÌýƲÀÑ#,• X-7mI «ëI”·‹ô¹¸x0åÉä·ß<&(H8ñ’‰coÏÀ#?‚Ž.úÇvѯ+£j-š"X»íkÑ«!ùýǬ¢®4È÷°(\ó·8¥(%ëDàz¹ò¢Òý"D(ä€rÜšÇÄVíVÊP¿ÍxCGz÷Å8ÄÚ>äm…¼<Ç’÷¾Ä,É• óϬº‹€@_ªLÍ<Ó‘D˜>ùµ+rCºZz§©Òúp{íg±—zwØèÕ¶uòîà¸eÄ2@"¡PÁîPÃWg Êp¬”Ûú¬æ]TF…Ø"_mÀO?¤‰Z2r Ýø=Â*ÆD~¾åEµ¿›7÷€èÞ]»Q%” ºä·ç¾µŽÕj\2:àÕøìš*Ÿ{kBãŽèb[lÛ+NoxB¨ü´¦;Û²årŽÁ}¹Þ§ØÍ@szŠtNþÈÏ)åX¥æäZ(®Ò¼G‚ö.–y«±Ýˆ±­iIÉ“K±lÖ¨<}} ª^ŽºœŽL˜·‡Vu^Nó8éJù'±ò ú/kÒ“C9F÷˜À}Ú@‹{¨b§_Çãó<Æ/'ÍýIU-À€ñÝ ˜çUrͤÅšh—àãIhùf­t=Š~×XJ½³N¹æéj¶F³Á'.Jè£Äd24ƒdë°æè©ð>Pc˜AÚBé?NP K롛Ϟ0]Ü ùŸiéXÞ& A*Q”ýÉn„¿ó!>è oBÔTçé2ój¥d%†C¥'kºlwÅ èvQ~èö';ín))òÏfÝ é)MÝ®kß›´ªY‘’@²ù¶˜×ÐMÞwgs€Ûq,×'ñ/­G‡½TnîDE®—"Ö7.‰Yv/CpݳeåΪÜ 2k9|ç¦zZ¢ ¾ )m#£Å’ݦŽ@³u_ÞšI9º hBï_ /lÀ`s,›·Ë7îņáºÞå`ÖÎZY .lFÁØ0"ÿÞFµjÞRtB-ÔÞ•÷b¡îJƮڕàö÷ô’µtHlÁY••¸ ðdZÎ#iz³|&(œ•Ö…)nk…ñ0,8µÙMœ×è‚d(µO¢r¤ —7{ÇΘ¼«êO»nÅül×xû‘>³üþq°¬1ÊšY‡“S¹.E²f‰ëÈã¶éQtØ!×η5zê;,Ú—jüé;Ÿ“¥ÙqÝÊóu]x3³%öí¨#)ÈN¶§Êü~iânŠ"ߥ Ñ»ºá£Èµã@_Œ´ï°súHn<„ZAŘ;7ÔèÌðß/ŽSÒ¸w‘Çzyûµ¸0Ù£YWã„¿7·t³a`}`:u }~ÛDæG L"Zp›ìÚº—ÍzZâ‡K®©Uée6¬À‹¼ðwÅ×™2+Mi°-ˆ[d±HiŽšK‚éDÂâÌÕ}dtÈj{ý‘;bb¿J¾ ¢i3 :~R†<6¥ Êh)BÉ<øýZ§Š’ Š×/_Ê©]»ÎMŠãŽùÍhN“~k⩞̱I$!bºò«¶\ÖßÑd%£õ›«3á³AÀFÛ#ž7ÙÑŽ;#Êi3)g)Á|p=ûü…«žçx¹ÁŒ7¹}\ȧ›é‡ìXÇa7Å6 è kKeÒôо»ÉÖèQ›S *‹ úºÏoo†§þkZ„–’3¦\^T¸óªb7å-Žé6ê†æºÒ çý(, \Õƒùî‘£ºãÛãÃJ„µ à±Ô(Œ_§7ÕŒ|qü¶=I#ûà.üžö ÍŠ„Œ€]¬l–ÿ*ÿAKÖ8>CœÇIK‰@sŠ &8! ©©¬ŽÇõóÊ]­ HúDеi!  ˆî/Vÿ>*‡døqù'+œî(¹ g+G·#Tq_ôñ)ÚÜ„Öjï/›Q’_õøŽ?˜‹ï^ñ>(G—Ç „_Ó¤”îêgzdc‘~ØÓ¼K¿²(Äó¡z6Ç»¾.‡t¾ÓLP$‹Bé3‘¡Xjƒ9Å„³xM†’&B”Û#^úMWLD¬}÷Y0ª ÁÊÎÚ¯cjBÛ‰|­`Ô)dÿû&ý±$âmÏÕv/Aê炱û­ÏHÑ£½&ÝÞ09Å\sß*Cõ´´¾f=½=ÞÈ4¨0V멬IŠr Ã!ù1ÃtIêu€/ ·waóä½?}Áv­îJN M¶íkp»ÙÂVeZÉ´(ßd´JOW\ÿqbþC¼»|Zç&&ÏȠΚ°)_ˆ±èŽgÇCï$ñlw9¼ÒG®hȻɸ\^aEÆ#ÎV™ !IuËÔÒÒ0PVµ©ÿÚe÷P;/€Q-½Œ:UŽVa(ûêOTèº,@ÃÂ*ÇOrxzˆD·+©7€†"ÔÞNø¤ýƒc'ǧ:ôúHUäõW‘ºë-‡Æ%ŸÞì9Jœ\tøTœÀ#š(¤…8xŒo‡åRÈÄ~Ÿ‹î>þ´ ¶Yˤ^+ƒ.R.²ÂVu ÄÖ2Œ5CË'¢(5Kg‰h"«UR0‘ÉÁü]šÃ©{¾¿"«J¿‘kÕwwܽ~ò}_oÿòr**¶b½*×9ËØÊ‰LL5Ö¾cŽà¯×v,l½°ùð¹Ó– ÚüB«ÈƒÄ„LûøÅ¾ÂàÝ­ûå8Ó9x6P'í§1Ñ”ŒC“ÔrFª³¬Ozé.æh¼é —o¦Bƒ‘7‚蟆®ÊÎÝҼſÝœýœ_›wUF-2Ñ‘Œø©`#µpÕê`—÷»wî Q:©´ VŸ1·ƒÎ13 ±vý ~;”Bêm*PD¨®N“§›³Hw¶N¹±ºÂ‚EçìÅœ : ¬HŸ­_5&+Ê´?^O¦ÇxΨÇc8k¬Å.þùUx[U,T뛋ÿ‹ROÏ›*÷79e•*ÍUd4‚TâBÇ]ò׿„'òPįT3Ž(u6±€ ØÈQÊ9ȶçÑk TÎUŸrv¶ ¾eãSªâï1!WÈåQ4Y»»ÑÛZÕ­”Š]üÃQ\FŠògâžE;+1d*MX˜L5K¦­„ÎD¤üã ûJ4òðÙ¼Ã:ó^ºÊ.©6Mh(Õ ³…î%?‚¿ãžž fË`idr¾³„ª^=hfDmÏ&VÝï®o~b²/‚TVE¦ñ½¯càósDt@XoÒí¨ÌD*-õ>8ª´ «Vý‰¾‹’éÆPòK€¼;ékÒú°²ÕÅ+,=þ0óeç–ß\4¹ 2Ò.¦÷ûžåú¹¦O´UÖJ؉ó{&s&gê››ª‘eqƒhÁZXa¬ ¶.`»ƒº´OÈòV‡çrà) j¾†ùÁÆžØn˜£9?ù9Ï7óÇ¿l:¢³^wÎâÞ¦œÎǀ߼9hä¿ùå,Z—j5ϰDnP¹®5HªõÐN„Žíš`ÇÂ~ïC˜ÁP%ÞÏK8bTÖZ3Ð7ýÒÄÓ„`7Äö,»1†üÔ#ì ë P3¢}ù9WÛÄêYIɳâ™Ø UêÙIÄôSúZÀ‚þ zeÕwÄ/ò£Ë¢É@´{ÆdÜ ¬@êÀ=Åå[L4‡Žƒ§7– Í=z\;Y®³3LY ®9ÛæT²BLjišfN±+¦«ÝÇM ñåó5K/«×(®úí´ÞrK8Ì]öÍØ'M¦XXWêšfaòH /”UÙMÈxJusp¹ vS‡û«ú«Ë1Þ–T'ï°!xþ…I¬!*Û ~i2¬&Ññ{šFÈþ­¬–S V<êfÿöOôÞF YÁµ—O5ä§çöàÁ eì…‚h×Ä%§ÂÎzøjÒA³º[í3'›PkÜõ¡ÐZøÉ+-¨a4 ×Âlsl×^ŽF{ß+>™áÞŠÑÆ}=¦UÛ 7lë$mv÷šÛ‘¾Ê,Öµèɯ =ß`½X"{ˆš}*Øðí×­ôLlУUO¶7gpÓ^chŽòëèòÚAƒ"Í5êLÕ ˜nu\¶$äâŽíbÜúqžä;.bçcÆ>Xþ ç«“ÐH@Ùº ' aqÍ`à‚ÊsÇë“t±™(ºT;®?F» PèVúθ1ŒD6{º~]a/¦CÅSb±ÚÜ-uÚE0™+Ü"÷ø± ‰íPËLò±‰ùÂ(©ÓaXêçÈÓxóÂPÐ5öÂP‰¢XÞh÷³Î„ÒM õRëÕü¾¡~~½Žÿ@1T9­WesÕoè’ŒW–À j%_N¯Ö£ëêÙ´ÜÄ{Aζ—+¬¶”ÓÏ ¦}Òð[|&Luhf‡Ê |˸ÄnØQD+¬Ø˜TNû„¶ÆËÝGD¤oVe·–¸Ò²ë/³ÐÃÉH®õ¿!î…ë—c2·Cè—äáÌp>£¹rÈ÷w¨EŸôiW™™\œµàÀŸCSµ¿úx:OjZ{kê2¨T` éò”sN^=«å ],y‘•‹¨ƒlÍ–áç½Å!žŒo—iÛwò·N¢'vU ŸM <¦:$‡…̉'Ô>¡üŠ~PÔÃÏÂb'Š,ª) öæûU©‡×`l¸1m[/£Í'ªkí}ºíóüÌEÄæõ ‘‰Y{i]¢†TÌ:ç<Æ™QȲP³éw͵1rÀ…!¿¨{4žÃž£k¾‰Éå2žô=`4«¾`üÓ°úO0JŽ]•½€‘ˉƒå„ÂÌÕ‡õФ:œ H´,T°ª|ǹ;ŸéµI ¼ oê¥ ò&Qr‚:^ã,€¹zé1¥Ã/þ{9™®ä1‚Ë9ô#A%ÄËífkää&jÝj•#¸c_Ì#M磚dîéºÚO%æyî©¶Ýð´¥"OÉ=g5D¨àb˜Œtwâ—Q3Õƒ8S®¾Ì‹Ë;Ê`¢#?ÌèêŠ-ì{íhz.á™¶FÊø‰Î`?:=^ÚÌÐõþTÈËó•аù>Lt0 þ™sÉÚþ¨Ê*îeNfÖO¬‚B•&÷†2þB*ŒBØ f÷Cˆ ’ו»½6uZžÉ¢xMèëªT©A†º(¨3çmòªù ¢ÈÊ>Ù–š"t£;ñtÈûëÓ)^N©hÌw #’ZéØ(ºHUXoîP¹[ú ŸbÌÕi›Ÿÿ vEeòîœXÛšj†§¿÷HVm{íJ7ŽEÞXm!u…- ø”kïxHÚ‚‹#§–ÓÛÓן¸èÝ^S&k|ŽP„3p\ßYÔ’}t-£ä·áÞz* +)CSmYI8x€™Ñ¬“µåj¢tOJMâ‚Ø9( ,XW§^œæ¸^ðð sºX 5=ÚÑ7âü(œ‚Ô=V׆²K¾= Úq§ÃÊš­ÎÉó#_pgß9bì#¡`L²Bå™/T¶  êeêoôðNH³'o?¯*Ê»°t.ªr¯¤åÆzJ:á¹é±LýG™Æ~3û@Ê §@ü2_kžâÇfíɾC”^ªè¥ê¹8Ã޾é¿+.Ñ©£µ™fbkX©Oà½%‚‰ãcŸX‚w²^y-‘8ÇJûé@/SvV9ü5“WƒâÈWÎ\|Lùyø)ŸØ³!dxí¢ÌÕëIêó»•Í¢ ýú"¤ÚöxrÚû\hÔzËêªÃä}õ쥥gѰz—íåºÂïgs¹N÷T˜¯¨qR¨ë~&þ«I1T™4Ap™WˆÖÒyé•¡í óAH*Ü/€ù]m%þu ‹ŠÛ³%x|ò•½(Ù×|?ó­9ĆݣçÚ>‹­»•v½*ëИé£ûÙЪAA(Ïß9*GÅSöN¾¡Gôôa;|¸„8¿roðü\²ä yÔa† Ô]·.ÁÊž”]bç?ÊBˆßË#)4’âÙAøh›ãúR<,—Fâð«ÑN«Û)PÃÎF’Â\Ì1Á«#…„'Ëé3‡¼êUm‰b¤óÜÕÖ8ÊNMû–CÄu b=ªÅ²«ìáMóC¬wò!^ó)”nFoEºÖ!Õâ™7†OŠþî¾öØG幟ZóP¦í‹ãP³)³Ì*ÈT™Ecw4LntguÓL 9¿%¿À“ÐâIÆ ”èv²…ÒìTÂBF"ÓÖ¿NÔÚ›…=”Ͱ*º¸—Íz½ÅƒKÑ!¤¤ûúuÅ/ fJÄ=æûϪX~wq™–hˆGsz†ÇAQbgm%ö"8á€äg@™ÉõXØ'V—|ÙØçì­DLÃ+R`L†];¥øpÎáØ“îg°2rBd KX¬Ò1>.:¯jId± S/‹7‹ZŠ8pãgáhÕà A-¿¬íÌ8­~¾3z~Tµ£g?QMKùÃꪘô¼vQõy47‡Kó†ÂÆ'…™û$cóþ‚À¦/Ï{Ïfý¸œIùj¢ÓŠ©°In£ ‚Õ#ür„ßàï¼—¦Ð\ú–J¯>"ÐÊ1BˆªH#ÁE%¤u8ÊYË!1ŠRüNÉ\·ŒuÛ´‰Òlìç@˜1×i}k£pt¢¹H.¦¿[¹$º_*}Å{]KÀ̼Çÿõõ¶ ýhÿ(`k¥¬Kå³óƒ¥Ú r£QÍ©ç q/É3ßÄoTc›M¢´Ë±¥i²¾ìîêg0ÒÀŒ8Sšt¿s}ݰNô>O´üà w¨]A85™ÀgÛò*ÿó€þŒ¦Uûõ-ÍJ4Â…šÚ©s:füÆgu[°…CaÕ_†Œç¥SÙmÃå]¢D à^Èlá÷Yƒ·v! ’òü 1jÔO͘~T&GšN~Q' lLÜ|¸Ò䨚û+ûÉÍ‹6óСzít}ĘÛ5aœÈNõ°v+ [ŸúÕoêYȨ¢GTçÝ;z$3*졹0Œk÷¢øÓÝÃÀKPÒ°³]fÛJG¸®¼az>zgæ“ȇçÚú/(¹?6]Ö†ïì;êœÂÈÿ0Rßé?'»Š,_ù2.í} ¬.ùÜÊàQ̹û¡stàvÊǧ©ÑoÜœp]ä3Þ¸¡ kÆ×flú}~¢­LóZ ÓBY«üH Þr(hE‰ÛKL°·[Kó@†àf4Q(íÖcÙuËïeöþ¡ÖNy’'‘.q¢9&ªËÕÓhB[üVjˆ[p1×°_0rvÍŽÓäæ——¨Í3äðv\²¹’·4GÈ>bpÌcj ÅÒñúü…HîÀå¦_[®›öRÙL,zÛMÙ³JhƒTet캪hû~'g~+§{òá¢Λÿ±¢´•㻆CñRP5®‹A„’ĈàU„Cÿ Äeó{s[DÎ^ó£ÅUh¾eÈÛ­¹xø§~í¦«#òÏUmmi;2¦ÞWAñ‘Z¸7Kœ)u[KHµß`ÊüùÁ²S™æŠåG-}•\«ÇØñ¹ý89lmâ÷iר%“ø˜ ·«Ô,²Ep‹fz?õ~ØÖŠé$¶iñ¼¥ìOþþjZ4Ö!½žHeù-õ>Ùчç ã3Æ^ ;ûµÒ¸jûÛ APSÝNŽÈà<×µÈHdš¾¡XiÍd^«d†`¶ÒHŠöo¥Äþ‹º±~]{W#×ñ‘ñ×+"n¾ºìrãëŒý¨ rén5ˆgL|ðph»D°Û´Š;CbS×û©üw<¢e­ˆ¯>¥0‘æðûûÈHÑ&È¡)wþøˆ—~Ib[çQ­Ç|æ_&Êú‘EfdCÍ3£šJ¿¼n“bÜvÈIHÒûìÝ•v4oOúbÄä‚]ýD˜Dát;\{z‰7y±‡4:=nk¦f{*üÐð–Û¼ï­>ã, ±÷µ]ðÎC—%vŒåãÁCvµk4©ÇÁVàüaEÅ"=£^Ìá §Ï>Ÿ9VFÓÌ&@õmàj–Ó7ëãZ*ÇmìX]x÷šgdÉØ‰‚?¿j¤W¿çüªR¢C‰}}ÒñÞVȰT2¯×ɳ ù¯æÔ/Û}œU¹ðÒ,˜†®Ð†Þ§®l{Ùë¿e…÷<=òÀýLqø“¾ÑÅ”‚§™ âRÝÍc’õž‡wr^Ä¥º“ÖôÓ“Ú¬ûa0Mù©6¿w# ¹² *ú{Ì^ã«Vj¤ŽfàŒ]@éêqr^Ñ™‘Õµqá©|eQº0Ä%fv÷ûPõþ˜á¾Dó¯&<ìªî;g…àBŸÊ4yH€ß7®ºb*§Ó—_b´ìØ ÷§“‰°2Aç°öòÎÔ8«Ì‹ßáö’{˜+p€wÌ©³ùø 0ýX[Uiç"F’2OÖÒõÏ V[ÇvkdÒ(ø 6ˆ¥p›€&œÂ,8D#íð6§4ù˜(ÂíÊ« &÷ UF?ú,OrŠî$m¦ÞRùV”0ñOÆ.íi?6ž"©OãݨU(éB²7¥kz´¦£5{¨á® |ÓyûŒU–ŸÒçQĘb(ây’L­™Èm8 ´»m¡ ?n…êÅÕ]›_¢ðÍÛ(}Zî­x°à¤Fò¤4:2šC·@¯Ç)"<º)»±LÔÉ"áìèÌânøö»„„,%ÙR¼{Ö~·!bÌUn܈Tûô°¬öy¡U2Þ˜Ÿis·rOwwý µ“ âÚßT8dvÒ¾X”OWeþ9¬a‘C\Šž#Ä[‰„´Þ?¿o9´{öÕÍsé=©Þ²ó쬛 ^Õê2=$dãØS `rf$KÌDOÝpèú"P²ìá;žAЧ‹Ë~ÉIJáĪÓÂ…ˆòãв;ÚY›Ê—cåŸÈl>Ç©ÔéíQZd¯€âì¬Ä‚sbÅ ëËÌNÂz†Y·†‘bhÑ€ÁþMM3Ùa³E ¡˜OzÒ>à€s5{ìU™&™à‰9¹ûp s2N¬— sƒCk$–ƒ´É­êà¢r²eNœ*°’UÁ_LÉhbá¥E@¬‹ò.y&^£ôä¹^[ç>QD-‡ oJ  Éô}¼ž¯óµ»Uå‚´Ý„Í]ë°iA·@--òÚ¬””4NI¿"–çÞÏZ+ ’æfyÅ*‹5èxcõ§ò F­ÀB~˜N–Ö¥½šþ$1>«*»H+O{CÙOýµ#×ßëì$ƒ÷í÷bŠâãnç&7Ó“óËð¥b¦JE ¼ +ð<çÜe˜dh–™2¬1X×¥‘Ç#ó#)»”öf™c„…GM•ò£í‰Ëï^_T,Ž Ð)T–¬m“i²UÅm¸+ÊòsÈŒ²ûvTãÛ–ªh[²‹øC–P-ª§\;ÿ…‚=Úë°ŒZeËAûLǦBßmá¢Ç¯p¼­0yAúÝa­ ]” Ä†{æØréhôðÜD¢“í7.qÆ *5Íåàt¦; wíÄ Sv;y,¹:Ëç–eš­ÏÆX­­jÚ9gdGšþmgpâÃÇ’k'`2ñÈžm€ÖI:Ÿ¬v;‚§AŠbÅ×:TRæ$¿ïqÐjaßf'ãIp$îQñº†V­¦Uð×%éÖÇ¡åLq/~‹DúI é@ïͱ£õúFMÁõmùýö1ˆµé  gÖCƒì榘C~OÎÝç¼JÕþ‰£.ÕÚÞº™´¸z¼¹ïšÉÙ}ƒ¦š;É%¯Ì Û?à¡>7ûév&цHƒÖÖáâóN)(ë=†nš¹µe¸¹û j++ÀÕý6W?ÉeÒøãŒÎ~I%·éúÁ’ÌNŠ^…äÌ<®Ò.=#°¸2hÞÔ'Jæ~¡&r…þdw݇vå"GÒ0f JçoµÐ²ä{Ðj¼þÑ-Äܬè‚B(¥¦M4ʼnߩÂô”›¾ÍKÿºGaÏ*B†¯FÈ×_˜ç3tNqº„“¿¸S|)Ä-hwiü÷‰•|x¥“ ¥OÉ4 Ê•FšB¶ÓV8ÅôÓPA3¬:MÁJ ‘TÏ…$žIÑWv˜êkM¹ðt¥âSæ5~8¿D¦EÀñQ Âl2LÓÝeêû†¡ËË"–éRúó·ìoX²Ÿ÷¾ò?$ç$U*½¥`Ooä’*¤rİó8p@ÙsaïŠulÈN/²›êu0B]õd÷OI¦©´Ì¿Ž3|á$¼_¬ÚÓùÑqí/’¯R¹à¼)´m-,S+U’AtUükšœ¦e‚<7 »K­4-Æ[Ϥ®íõy…5£¿*Û-<ðþ(eRa±lTÖŸï~öyÐÑc¼¦„KŽëƒ[^±ì:¬¶ÙÜqiË3„ãP´g|=Q½ZçG ¥Øå1ûL¸‚§ßŽþl>ø Sö¸øt<’6 ‚Ílùش̽ƒ¬zýÉås=Ô0Ü”oÅèÑ`üq±E߈‹û ¨¼Á­9Œ [ct~OZÖÓp‰ÓVw#ošÚâ ñt¿g¶(«&E n2>¤÷µáUMÐ’$ÑS9–îM4ÔÏ©iÍ¥€ýú·ñq9y››¶Þá*Md‘Œý–å]&µP)°‹Ïsx Þˆtµ†^– —jìô-a^ë§Eè>™—AξR˜-à9çÓvÓÚ?“Tc§ÐVÍ iål¨³ ²J~=DÆŒº @öä3‘m²-Ì8 —ÞÀ|­¨N¹¬ïù’à‘ÚÅ*ÌSÐù4ùØŠä{®pl2±ìÍÌ¡A§êåSÙbbÖc,àÖЊhd?¿g5‡ ¡þ¢œ„ÿ ”6‚Ð<ÊÿÒ/ÍÑŒI¿—ÑÒº> endobj 90 0 obj << /Length1 1109 /Length2 5260 /Length3 0 /Length 5954 /Filter /FlateDecode >> stream xÚ­—u\“íÛÆIA¤KRFwŽé®Ñc0„.H§´£K•nPADBº[@A@Ê€Rï|ž÷÷èûüþ}?ûçþ^çq×qŸ×¹Ï½q³ƒŒ…• HG˜:á#,."~ ¢g$.#áæVñ‚}àH„*Øv .++PòuHˆÄ¥ïoß“"ᨠ=½àÎ.>>þ_"€’;Ì #z`˜;Öv#!p˜O @ÉÍ `ôëo€ÌæåƒŠˆ‹ pˆÀæ Gˆþ ¤…pBdþ^†úzü§äóòƆðaCò°¡H„[ s"ÕGb÷‚a“ü„ú·¹º¯››>Øý—ý¯&ýWìw ü_ÒÝÃ׿ÐCBa^ˆKÍagÓƒAá¾îÿ®jù€Ýà%„³ ö÷Ü[ƒ‚à>€ØÍö×: ýwlßþŠ jªo¡«¢!ø÷yþUá“@\‰ÿbñߌíŽ<`-&"&&Žb?ÿ¹²ý×^j G`BJöò’`'KR€â8 À°EEHì-lOP'¤ɯ㔖ˆ*ýZú›nDUÿ!q€¨ÆoÂÖô“,@Ôàº-5úM@€¨ño’ˆšüCØÿ&¬§ã?$‰UBîî¿ëâØg…ýXgç?þbÝÜþ@lD÷ß(.EüXgäï­±Z$â°Ç%êñb£yýƒRXòÆžÏ?ŒµöñGþ!Ç&ñû±îþ¿÷ƒ`^Ëÿ{p”•‘„’a )ql‡nd¤ÄPÿGñõò‚!|þúNb§ï?ìÇÎ* ƒÌM#!r‘®Oš¢+BÔJF+ p•›Sôë;'^݈˜MÅu{: ã)°\gñó9š†|ƒpƒÍÿœÙ;¾#ØpH}?Ì3%kêrÃÏaÔÊlAë®{pœD|¥hoš<Ú‘Â5_þP‘aYÚ“wðþkˆOÕä Ñ";N—µ_CWN¤´Œ…:ÚÍ4&ªŽÈnD™åY+³äO™‘F°4âCÜ"¸ð ÙáKý³„¸0ýÒæhk\Ñš>wJÚ1<5ã2íîæNHÔ”dK,IÊim;ÿù2WTaØÄ“’…˜”ÏMK«µp¦M ¬27ä…ˆ„/NF}(Ôõ—©Û(Ïó^dÔ·ìϷ眈aÌ–ú;ma¸Ïç€Á›%…c÷ù g´ ¼¯»—[tj?ÍlŒù˜©"޲“Î'giQ#9—VÄNêü—² m¨r«r³éâß­‚†Î…œvÓ¾6 ^¨$J\uÔ(ZMHÌW€Æñ—ßÖ^ym—0YÇù! öjï:]^†l:Ë&ã‡Õ·êñ_]GY^eƒÇWh~š ¿•ö¸Ì=ÆZ)+9ˆ¾ÈÂÔÝˬ¯bÚ.ƒ1®“ÎĘ8ŸPåSDØ¥¸däbN«Ì§NrZ{Fìvm³Ì[3Q9™C#ÞSÓö'V?Û¼ÚÖ –^€¾‚1ï@?ít¼Ñ€†¯äü7c’§)‰öŠ—j«b{BFöuf]”ry¦ÛÏéY‡ÇDy‡IÒtñtç$EÁyœ†•4XC;Å8‘»a—h‹)—ŽÞ®ÁM;գ˺þ.ëVØn†HU ٛ`£5¿n`ŽxÓv{M€ ¹ëõv”¸øÆ­Ö˜Ì‡x†Úö3§î$ü]”Á½…FãR6çê‘7Òbý*?©néeÅ{CNÞ6ÛU[ˆÕh©““ c¿ZD²òýA=ÌÏäý¢4¢ÇŽ|b\uBý•UÆm~ƒà¡—´Ó®/Çð™;u"žYBrÒ‡¾ç°¶LÅøêQ›¿9¹oœ¥w”î‘^¹ˆ“'QŒÖ¥?“¢œi4…4g~l*‘Rà¼D8ãQš5á›J~) ÓÇèÇl×h£ïs'-=>q+E$¶o}sv]ͤökˆà©Þª0Jf¢ÎkÐ Ïu°’ç«r]4¸¦6»ˆé ýáÀe³=vè«èÊ®ž_’‰“ZívL¼V˜"A|*¥tžÄ›¬9I¼'°|‚»«ŒÖ *.4oD•Hf%1>_Oë\¿Í§ï“gzÈññÆÔòF¨s”íšnþfëc)m…åˆÏ÷¾¬]6iüLbSAp9ßo›Ff‹Ð8½lÃúló—Veï·iS)ùH/µæöåü}tGŒÈŒ#ðÓB^×tuÔA4sú꙳ÝûdåKí+§»¸\b–v«÷l XW|t=? È®}H·+Xºà5ï½¾¸J‘'f”™¡ý¢AÍWéémãÃþ! .²Þ³ñe\SåÕ±df/_i9 )ê"g<èeÕT°È¾'{Xr\µð:ŒŠ“sŽøLMÉsS(™[˜Ñøµa•r*Ú|Ÿ§ù0ÄÏQÖ Á!`’nàÊ“0”¨‰útÛpD¾Z}õÃÊs«Ò~Þ$Þ{oœžé0Î¥ó‘XÖQ‹s’úË#sé·AŽ¢5¯2¤‘?>fÐ&ºoµ»×ñDVúÚ†·÷Dº‡—£‰þÌYãr]f>óHj"gGçT…wlˆP.fX|ú€9dÆ–õŽêËÌZi‰Ée¸ßcÚ\8=Ä7n·a™*ÔyÚ2±šªŠóB ǃJå£Eµwc;ž8[ûVõW).Sþ̧ 6.ÃÙCò* ×!¸ƒ‚q=ô–ù2ò/ü¤ƒñý=Ì‘iûk6nl†'; b6ãW²ÄÝz õbž_‘§ a*.ä¨"³”'z’‹móu)«ååÄz'³*B…ûpÊÜ¢áæëÞ>YñÇæ¯;eD¶,Ë.=DÍeiÄ÷‹v9ÊDÙ£‡ë䈲 ]1FûÅaÊ[<ÈØòÈ›4/p—0@âÍ«;žzæmvÉAÌ”²ÂIyVÝ茠 Ç%5±ŸPãÑõ÷5¶œ;•ro¶D´Núgêt{¤Üüf7¼û3INb5/êJœ>pvW„“Ñ×o‚¯awUÛ­`úÃS ø¶ßÑÝ· SDˆDŽ|M €ÔâÉe†´Î×'ƒìµ—ú´ÇSOü~ÆföF˜KC̱‘ÌÁ”ù$€V½éáÔ¥œl®XñÞFBÞu2"Q(\åâ>ûÖ§âFÙ‰g*ƼÉÛú¤õVrd.ËêÝ© B €1“õ ¹puÂ.~*Ÿ´ ÿ ]ÃÉ››¦‰^±Ö÷0jIäìÏF÷ÖÏzhyž@›”ßQiôÅÊh£]è¯FTíäÐÓPâv'7í¥£pt¿i¾Íi¢ÌN²ûÀâš æä_¹ ¼1P¥«Š/š±*|/¾¬§¢á¯[ö`Ó!gßš§P#ÞL–Ô=l­Ûh°G$Œ1È  –Vì}d!GÐ2ýäüœ×Ñ™ó¬ï é¨j€U8ü~•sFùð<÷Û›þ<bµtåEÆÕ!ñËwä>¶­˜z²ÖISPnl‘E~Ø °åƒÒšNÓ3zÍû0Ö]æ¸zm,qèËÙKêôGŸ„†qܸ¶v}óú·®…N­wÀ¼E‹Ë›rÖ‘æó,›]Vþ|È2%%h9ï%c%Zp°r½|öÁg @ìˆäa¼FìyWTS#|éóê3Ô¹ÔA“i_‰9Å.yCLÆJW5H1·:³*66}A‘ÞÅ%ž"f9¿ÆÂ@¡«Aûê‚Gï¶™fæô‹œ« oUERF˜§LØ=r?x¶ôž¬)ïáÐÜí1‰Á¬ŠÅ¯«(çMo`ôá‡ÂZ6§œ¶G&zmÓÃ⼚£MQÃ$%)ýVô[„}“˜á>ðxÍ~Rk¶‰ˆ Ù8`†úì <")PiDrÁe™äO÷xÅYo¸É±¤Tö¸_®y7–L•ý±Íƒ¹!›PÝú‰Ã÷JŒ7¦3ƒs1gÖØYoøÒ³: Í_1;Ìwù4¯±¹X…8ù¸¤ÂúŠ[ðj¯5‚k‡ù>'°÷ ⤸¨ Sœ&[¶¡ú®‰ÔLÞ³s#¢1mnZ.‡x}Zy9¢A#Q»°j‰q>}­äx¥9gÖØ^QcáЮ–óiþûDpTÕ~Ò#XñWèkrˆm÷Uü¶žÚ3ÕÏ“t¯å 9äp¤! ¶OÎiÒèM V'ï+4ß f–ì7VDR5Kq<é“©¿Íd%›Þa ~a/¢È¹=òô&û‚Øz¹qèÇoðoÍuv;¦û{…$BHY‚6K§•4ý`¦,Ÿ¾\°·"’Ë=dRó„ø ’*Â+ÙTáúhÞú~ÔzQ«Ïó’ºçNùe-ÜÕþZHIt«íÒIPT(üPœ‡[9m/(ÏY¾3{ýjòóD ÷˜×店Wõ¬]ä½ÕÏZ Ìî”·<%º)l±šT¥ü`ãK õ±iC„AÓ Ì«Éí€ì&eÇl­š ÿâ8ûÊöffÃ)E‘èmG»õªWA­œ5ùT‘}iÏØëdËÖâŒ! i_yÆ;Ìërv„‚!,\¯…oO­ÜÒ:š£ÓÎìt(ãQø²=Ë9p§K]gp`.?.Æ€Ðÿ懸#Ÿ9åŠsæ;&ªÒJ¬oPvß`{—‡/R"ÅÉëÊÚl&s°…€‰f\gÀþŒ`ò°!TDƲÍw3ƒ 4òA´!ûÍ?Ýì"mWx¨ÜwÉñr£Œ@æ5Ÿ*Õ­°»Ý–SüHŠºéÅ–]¾P‡Ï6Ý>2ÛY!Îï¥ñ–¢k¦F_ϱ–ÞÝrÁK|¯eRv±î?´¶7Ó—™?«|[N ï<ÔƒÍj“Ú^o6îøÁ÷¤–WôsF ¯Ù8€Ÿ z{½ª#fm†›æ«ä€ùy®q{ÿ`SüÒGKê4áó,´Wù—ߣ. ˜ÍõÞ·®p$F ám„¨¾¸µéØ›kÓ* ¹’¨ÕŒ%ô÷$݆8ä™30é9[*V#ï5§–„h·"(ÅÚÉÄÀ¨ÏzŒ‹£²ÏËgŽÂšù¥?7çÚ´(ýX°¥>bwŸ.;® eótµTYê¼cé#NI†~R¯RÇi̸á¢ç™A¢£A6¼\©Á2ÔHiV/¹wCÖþu˜VÑCðÃ5R+íE¥“« HĪP³˜“•ìDv"ajõ.ûÛˆ½‰D7 zÐl?Wå"•U{®û·åà«<Œ’lŸ¡ý4Zø6†Ž´§D|¤R•Fý”“8„0<æ~H½”èRi2J~ðŽñf¹uü£îËáàƒµùÁ>õqߨ†“üÂdá=Âgý ß§²ô@ö%&µ¤‹”_â ØBµ+is v7téL?:nvU¸F}/Ûn¿oáÚ¿dH4ûvÝOツinüg-6à]†'YÙÃ<ŸzÀvÕš÷R³Ù‰ƒ®Á=ýÍ(¢Ø€kÞûuÅ*‡¼?›ø*M)t]A©Åˊл ­nH`BvÆrÖÐ&ßò¦™ÛPÛeQ‰ö”,´AîÈÕwXçêžšË'o«€uK¿ ¦¸´™­AZˆ[yß —-JŽc"oÀjˆ ÀW¿r•ÐE6 QX½¹P —n5ØEÑyór+¡uçxZB5.ìijIC5Æ»zd,ކ,È6{§EÁ¬Á¹“ ¥©Y×4A²K§DÙÂ]¤Ü¯§lòy9)kGÂ<¿‚ûwÅžƒ„±!®_hÇF¥[ºÒÖ9?ä’ÆÍEŸ?H¤Ç‰Å¾µö<*r ðc 'l÷[óÖˆÐÞ|}Š„ÎËa­Žhü—ô¼{0¤a]Ô6öMkÃî ¶˜—Ìôºk˜µdéúòuÜm_Sôëâh+T1šQ¤@B¡JzÅлԬá^ª.éëo}GLf¨Ng|2¯qw2GµÅeøFÐýs®P”Õ9úî~öµ&‡Ë0zö ¾ئP€kѾñ\DÒæZ­û@n—à¨É`¬á%õ¾!]Ý¥ÜBð±åòËdWY?p·~ñÕÍvëFzËÑìn6Ö÷¥â¼­8`λ¼8îà=¹¬ŽVýé™CgÙûÓ)¤1ãÛDã<ªº»”5]›¢_{B#,R/V…E…Ø£0囦ï†påDNøe~¼úù,¾x¡€Qœhñå>ļ«EL‘»ô™¼ '8Vòêqåï\1p…UÈ0Y0e¾Â4Z¦È&]JÃ)©ÒågÏ€¦=0ç`šÞOfA™wÊ9Ûúo–TJpòP^æ<ø*øe!E c§‹5wí»ˆ9á4Û[2¶}·+uÒ"­Nž*£Z0d²*bø,åí—ÐÌœ-‘C³xñä­xáÝÉ"Œªÿšú_Vïï<³*élŽ«ÏÙ¶6ÆìäÉÑÃþøÇ¤ŸNBc-ˆìÎ[Zv© ÇÌ:Mâ}yÜxCz#«tEê¹6ß·®÷j÷;EØ­$èñ$çlZ\æåjÚ 0râ)[J¨^ƒM–m~qú™ÂÞGqd>á•’D[Pº>¶†š’¹ ÒâÝŸÐŒÕ.iÉ\ékGK8™€ë“®˜Âñ,¶Ù'TgìCß{‚kq©Ë0êt ³œ½ÆjÓ°÷ »Íš¹<ÄêAªU:U™—¨A€ïHÓûîW;štùÖ/ËB¨;ý1{8:&1}Š´fÊDCM<wü>Ò•l27Àáæøç»AQr€%¹á]ê<jî¢á>J”ù>¯ÒB€ŽŒ®ÿv}vdØú\—_o†M@Ê>ÍÈ#£q£ÔG¦–||pn“‘‹ ÒcNüûäËœjúea’ù ¯¾àÜ}Fý1W'ïd ³çq~¤•®¦Õݾ]f+ŽW» RÂüÐǧs¸[^A ÝGÃM­ÇWNR J.¨_"N¥¡ŠçììÄ„²4›ì°È‘MÌwáü½ëŸÛnq‘_StÖPqlÊM$Ð{jH6Pš<ö#W ž-*Û}$úmò0÷|ô…ÖȰTA»8É«'þ²£ v5y‹3^ öc48€SW¨©(ùjzܯYxÅÍMã¾ ý¤0¦‹ Ss XêlF¶™ˆÓ ¶›gQ9`‡jåáÅ[›Îôâ!q‡7¤lf¦Tð©ôF˜àÎAh‘猙IÐé(Ú¼• àªÖ).õHŸÐJ†ÈíØžKWŒ¿ŽùþÌLža6ø»³(OÞ³Œ=!=b#Dì¬y†ã[¾ÐšŽêû±Ì"ü‚wt*’: U‡÷{ØYžÛ‰—PQ«€†œÊp‰¿¹½ËxB0—uGwêÞœeE–xš?$¶ß%"%–¿ ‡öjŸð¥”óÇ¢%­Yô™pÚã@Æï·ëS?ù2«"&W¹¾l <ûý™ŠM‘ÿX „³+S -¯ÿ]u( e=ÂõL{LIð¯ÿ,²õ’ÒÚ›W’ãOCZ÷2RK\DÎmÙî¤Ò›C—·I’¿°§×[Ö_‰7»²×âe¸Ñì1ï3x'¬‚“Ç]?æ>ôèÆÇü|íÚ¢o™³uf›Lñ%ãmcÎeÓÆ^¾Î;’w”Íû"Ý™»ë?ÝY‰=)‡K£qßYÔÔñš‚aL‚»`Ü*ÿ¶î˜ endstream endobj 91 0 obj << /Type /FontDescriptor /FontName /UNXLCG+CMR12 /Flags 4 /FontBBox [-34 -251 988 750] /Ascent 694 /CapHeight 683 /Descent -194 /ItalicAngle 0 /StemV 65 /XHeight 431 /CharSet (/A/D/G/N/O/R/S/T/a/b/comma/e/g/i/l/m/n/o/one/p/r/six/two/v/w/zero) /FontFile 90 0 R >> endobj 92 0 obj << /Length1 1052 /Length2 4372 /Length3 0 /Length 5044 /Filter /FlateDecode >> stream xÚ­”e\Tk»Æ E”\t304(Ò -!3ÀÀ0ÃÐ’JÇJ‰€”(! t§"a€  HHIÇ÷>ûճ߯緾ÌÿŽë¹æ~٠…•ah{¸…“Tõn‹Ib"¢ nnU ŠE QjP,\“•”½œˆ( &%'.#‘qªhw? ÂÉ ð©òÿ*’”Ýà„èA±Îp7¼† £p¬Ÿ ŒD·ux·ážpŒ7&`,`wB @à_†´PŽh@úï0ÌËýŸ”7ã‰7ðáMòx‹04 éÀàŽ °>ïäÿÃÔ¿Å5¼H}¨Û/ù_Cú¯4Ô ôûß´›»ŽôÐ08õïRsøßÞôà0„—Û¿³ZX(á ŒrBÂÑ¿CO „/fˆÀ:8ŽP¤'ü¯8û· üÜþ²¾­«§ej*ø÷}þ•3„"PX?÷ÿ¨þ*þ‹Å~3~:„/`%*"**†/Ä?ÿü²ù×Yê(4 Â/„¤Å` ~ üfàI(Ü€ûâ ƒEPh,¾ÀÏ$pDc@¿®SJ«ÿ ýEÒ2Xÿ7ásÿ! lòÂß%ú›ð}ö¿ ßçð’ÄçÐHü®üÀ°?P Ã׋`G„7ü<>âôJ`ÄoËýÖ–ÄûB!PtãwŒþ!ØýÄÿ+̈×öü¥0ö·6þ$¬ÏZ¼´ß_øß÷¯¢‚ö „!ø>Y I@ZB6èÿÔ9xa0pö¯W ¿Dÿ°#¿rp¸/Ü43‰vtɬ* V/+' TqjHÒ¯k{Ûz9b:™ùx@ÇC`ö™ÅQE6ÍÕe’e6Ÿ&ϸ–@£aaI¸wgËÞvËÙþMLÛÙz~Kîû«Íõ»k’„ofËÒ,‹»ó6{V ùÔL¾’~d'h·ò~Þž)%m¡‘4¾÷ŒGœý6%Σ,F"ú“eZÊ…O£Á.Ñ—?l¡[¼¨Š.=J=»Kjû¨DW³NòŽ8¯˜ R‹J/Éä.毳ªôCPŸ@äøÑïÜ‚¦—mpÈakÍÕœœK®–×G#ª{~ò¬ßpPº÷Rÿó‰ *#ã©×-&‚€ÃÅ·7=¦Ëëff? $ftG^­²Zú˜ÊñåÜ–›|UE]ü°ÿøðy‡5$bg¤T'Ü· &¯t¥Êàe5çúÏ¢ÏA²26·é4;Ë+H´¼P/vÕ«µµ˸žÝ|§ŽN –Js±ÚÒIÇ¥ï÷hÑ`Ì^ihsFE¾ãMá¼…ø>ÿxºrw^¦! ó¦ „,ËçL†e”=E5¬€‘WÒœ¼¯iTÖ]Às‘Šk*-ôWæ^\ã{Û¸s/jÑ‘›Ý©…lB]GˆLLpw¦‡LwÙ‘{V£6md0ª´Ñþˆ‚ù5(£ÈR!}N îÞxD^óTœ”Bˆ<üùáŽãÜ”øÎ;nLŠˆ7o¯VÔ¶P•HçP7+*ÙJÓ]/Q(›„b×¹ —LÖ<ÊÛtd—èӡ }ÜÂõÇ´0ca³x.·Fqœ ÌðWžø×ØúšöÐäùÚƒ È$ZoŒs|‹\ÀGªÌn_ ÍSŽŠH2ì|lS’飺Æ®—XÖÖ¹J@Ã>!ëã±Ïwš¿x”œÒ½£PkhèÌÃÒEÄlÂ醱F’ì{²!ßë*%13OxÒDI¿˜«pAîð†_Ñ%–Ê¡N}('½Ÿ ÏŽ]<Þ‚ç6Ø~YçQ{E«‹ 5&†§ûùµn÷åw* ž4/³’ÙÙæÉÓˆvnl“µ!RçtpN)¹I«cx-ŸÌˆ[`8B2_‹ašÞĦMÔVR}òÁðu[úl÷©„sÑðÒí´¼j.]íϬùn¥Þ¡©Ë£ NÆ®>–n8H;H²F n^¦u‰¯yZÿsÎé ïzIÁòºÑ„ðO×À6“Ü|"… uˆè݈ÅF=×èçÐÌI*s£ûH§,jÂ%™Ã ñoå*Åjܦ¼Œ¾»ë—N¦g=d„^¶ˆžu²ªÍ“ô7W3ÀZ¢¦´>ÂÖÇÃr!Î᡺?¯è±æ,PÖ >}î^¼K˜³¶œhªÜtAŽž’úØòÇÎo‘È có¡˜ù¤Gå Ÿ³,H Âi¨r†šî!ÕÂR&ˆ´„·Œã©r³Ô‘߸œõ¾Õùot´[_ BEÝ?ºªYàUKsÃ5æmÉ‘A&ç‘ÔÃ;Ö™ Ãß–ænvN›]É¿ß|Qó¸ý>àòÃZ5Ô?8ý‡ûzÑ¥ÞÔžáW³©å ;»[:ÔšCù¯Å>I½¯¶„Ô$³öÞ|É€ªÝÝ>Õ4_¨+8i'G3½ühYG­u7îÑV-ä«ÀÔ=å0û.Á2Ï—[јÕ&•$¿ÛŸüDMïAв©ø¯½_äf¥‹X|}‚·ÈÏÃ\úÛ™ÚqŒç{Ý‚Tµ_o)LÄWuTœf<7»¤@Üåd„iÇuȦ¿†áRX?)Ú'Ü7XOÞ¼sæ/&•ÿ¦?ïH=nÁ{HþUîÊ`“ÔVÔÆ¬À$±O„Sg*gãçURŠ++K´¶Ÿ^é•´î†~¿ÈÌÓl@8Áå|†¶TáÍßï¯Ö@'rʳ ß&÷X$]À˜È9³¾bv ‹Æ˜Š{ð&©Úï|Y~—M#ùN½35±w'±£ýØ+bO²i@D˜(E“çíUrßÒ±ýµ+òO¥ø‰¾ñ¦Í-oœ1La&/IˆãFÛËT’®Cfl©?,›ÇC…Y Ë'GžMÀ`š¤c_¯ŠjÉíW'<¸å\¼ ÐÓÏi>[ãW/°«X\ÇN9æ÷Üþ)Ýþj(F [|G(,ˆÐI˱à#È|Vúf€è•ÜÉe#™GtîÓô‡p—âÑðʪ^ù¸^´î×?WÝX~ɉD²nK-6IN·Ù=•ì›ö"Ò0š¢ åCý{•Û]˜êšq/H,Xºa+tŒ;C™ 'ßçK[´ùdG¥]±!ráÑ‘s”õ0¿†÷Pð'œdêDy*YðÛ¶ÉïÙ ”˜Ü[€ü´Ól¨'¾1®--v÷ cøCN¡nG¯‚5#{& æ$7_9OÊcße ª>îI~k»çyð°ª–øÇ –á=Sàé¥ëç~su©º,åæKÞ×O‘IB;Qãï×ÊGz½×ÚÞÒ—Õ<å°Ô°}õ"/¦c&»þz Ù‡>[c¥îNÍPëóÛÁ£Ì+úà¨ô¡Ñg^ùÓ®Ü*‚wòmœÍ¢„Æ3^/ÛŽ¸H.;×õŽqŸ-ähñ[?4håAüس„—€{Þßá¬rVzÔ—áÇ–EÑËŠ³”ë(*q Þ{/±áßÀe©gÅÀ™+)8ÏÄüıi ‡·ý;Ee…xýëtC³ÞÁ(=T³ø÷]•ƒÇäL9—uåŠz8Š]§)‘n‘*ÕÈÄ-CcxO©…`Gxc4¤«>´s«ÔXר7,–+qg§d_Ÿƒ³µ¬N>#ƒŸYqäÅÒ¤†¬ „‹åô¼u\›6»~襲!l¶yLDÂÕ1q~ŽºÚ>¼ALϪ÷ÉÂüQRs:Y‘œ•juœGŽ" ÝòTû3ñ‚;§l)ãKÄÞøVÞ”àó³ÀÖé©›3ZCìÁsÎQí–ìè§ ÞóÚ}ªåçH$Ɖ¢¥oÏR…‘ó¿h<ßöWéû_NùÞ_ã«Gê; @¯kŽJæŽÒP‡îö6y UšÓþZ½µ{Œ* 1uT¼ÌŸQÇç(¡÷:ý(Kþæ—WoDYBä|´Ì—põwØÍ>Ðh½vónÿõŸø—ƒP (ÒuËvãæÔ¯¶ƒ8泡EÑåºOˆ/¤N6É“™ô‹6q];^½;jEÕ–ª7êu+ï3ü¾×@4¹zsgLô‹§¾üFA4FdcÎwæûôÎÜúùlõËf›²?nç Æ'œÌ]Ê& 1—L’ýo(aÔ¹iÅ“q­\ íÒ1®ô‘ÚTýÞ«ðµdšKߊUJRŠqqºš51¿ó¼`ØT—{Ü<Õ`ŠóäŸIšT+úŒ½É£‰ã›^$òdùXËݰÓÇ葪›ZöñÁ©N´nX„“çy°®Ì±Óšxš—þ3{Iƒ!Õ•7>çob·NŸ<ê÷gOŠþJ?5%"%s×üÙ•ö„üǵ2$_Îæ+xg`» –N t6VÇÁÐyEÉÂûi v²ÿÙ®QóM1Eæ§«}Ÿ#g§_h•w¶IÕ’œæhñ]o©r7CjÆÞ´>‹Js9À ¬uÚÇ”†U¼ñ[¼‰IŒ—]xI'ëoJtöÏ©—†QmZo³FÕ05%ß&ÓÝ¿¯­HQÉUÎtåm_ÒèzŠsŠª?%ûc‰´mƤW6ê«é. Ë-˜&¸Õ_íßÊè÷3Ø9ôD‘í®ï±Ú n¨ ¿9*bå!*<¼ö¢Ô/Ø“Ož|1î­Eì r)[µ¡Š:jQŒÑ${á#ÊŸ\ú³8ˆ”Ô¶ ¿M€¦¹¾Á+[¨þÕ"AQÂòo_è3C{‹Z·Èä’„ÔøÓ]`EØŽ¬Üº$*OŽå!mÍ·xšÂDÆ kܹz»]¤éŸM=vÍ÷~Ž#gâì hRrHÌÓ’Kš¹Ó4ü-™/>Цz‡9þ÷zÇ7Tˆë'í1 0ÕG7ü@EÜ·æš³=žüdꎫpø'sÃÔ endstream endobj 93 0 obj << /Type /FontDescriptor /FontName /RLMIUU+CMR17 /Flags 4 /FontBBox [-33 -250 945 749] /Ascent 694 /CapHeight 683 /Descent -195 /ItalicAngle 0 /StemV 53 /XHeight 430 /CharSet (/E/N/O/T/a/b/c/colon/d/e/five/g/i/n/nine/o/p/r/s/t/two/y) /FontFile 92 0 R >> endobj 94 0 obj << /Length1 750 /Length2 576 /Length3 0 /Length 1089 /Filter /FlateDecode >> stream xÚSU ÖuLÉOJuËÏ+Ñ5Ô3´Rpö Ž44P0Ô3àRUu.JM,ÉÌÏsI,IµR0´´4Tp,MW04U00·22°25çRUpÎ/¨,ÊLÏ(QÐpÖ)2WpÌM-ÊLNÌSðM,ÉHÍš‘œ˜£œŸœ™ZR©§à˜“£ÒQ¬”ZœZT–š¢Çeh¨’™\¢”šž™Ç¥r‘g^Z¾‚9D8¥´&U–ZT t”‚Бš @'¦äçåT*¤¤¦qéûåíJº„ŽB7Ü­4'Ç/1d<8”0äs3s*¡*òs JKR‹|óSR‹òЕ†§B盚’Yš‹.ëY’˜“™ì˜—ž“ª kh¢g`l ‘È,vˬHM È,IÎPHKÌ)N‹§æ¥ ;|`‡è»»9†¹kCã,˜™WRYª`€P æ"øÀP*ʬPˆ6Ð300*B+Í2×¼äü”̼t#S3…Ä¢¢ÄJ.` òLª 2óRR+R+€.Ö×ËË/jQM­BZ~(ZÉI? ´©% q.L89åWTëY*èZš 644S077­EQ˜\ZT”šWN+Àà€ñÓ2A˜šZ‘šÌuóZ~²uKÖômm+ë\_XŪÏùóÄÚ—7ÙD쨛™Rl:/P1½dÉ«…¶öϾ(á•l=U¸h‹d¯_OÜ—EÂk¶v-X1¡Át¿Þ`ñÊæ®i¼ÿ´Õ_y. ›1§õ‘´Õþ¢Ç³:•un~Q®?Á3/å…SÔâ}ßï]ãÒ š¤¥$e~sû]F1ñÊ»Ï/ËÚQ?ý¸mò»³·|<ċݺÔ/¦Ùq'}Iüö„+6­ìâEíÀgޝ¼xT.‘òGÀ¿gtÅÙ¥vÕG‚—U|íª“®¾~ª€]üRÇëÞ…_kü9¹öË:½{ápËñGúý îûd}dN<6Îø-uBÛošHºÁ=c¦MÏvHžÎzºq½aûÿìRKë~,KÌž³}Š¬Ë›ªÂå»m¿‡Š÷Öêyo›ù~ÉîÃÜ×v‹ Û_¹éÜÿs>§ß¶.#ßҭߦíÈè{­/þô­É™kÜ—öÉ\mü|¢Ðr¢úÿXöÑñßϾØad­j|ïÇéÖR/ü,à endstream endobj 95 0 obj << /Type /FontDescriptor /FontName /GFAWRG+CMSY10 /Flags 4 /FontBBox [-29 -960 1116 775] /Ascent 750 /CapHeight 683 /Descent -194 /ItalicAngle -14 /StemV 85 /XHeight 431 /CharSet (/bullet) /FontFile 94 0 R >> endobj 96 0 obj << /Length1 1793 /Length2 10868 /Length3 0 /Length 11870 /Filter /FlateDecode >> stream xÚ­–e\ìò÷ ¥»¤YRº»»»»–¥aéînéîînDIéT:¥Ÿ½ïsέçüß>ŸåÅ~gæšùÍ\±P“«j0‰Y€ÍAÒ`G7&6f6~€„’¦&+€™•U‰šZÂdæfv”4sñØøøØbN.vn+?';ä‰ vòv±±²vÐJÐýÄs¹ØÍJfnÖ H ™=@ ´¹y3Äìíê­p¨ƒ\A. f$66€… Ð `²²qDbùK“œ£%Àó/³…»Ó\ Wˆ(íß2é‘`G{o€È‰E ©‚hùÿ!ë“K»ÛÛ+›9ü•þïIý¿™ƒ½÷¿#ÀNîn €Øäâø¿¡: ‰SYظ;ü¯WÎÍÌÞ(æhe°þËdã*mã²PµqZÜ\ÜA›AŽÿ«2¹¿°ˆ)IË«ª2ü{SÿvªšÙ8ºiz;ý“õ¯è¿™í7CÆãbã0`…Ì— ùüç›Ñÿ“r‚-l­ì\Ü33o$ÈñÀ— `ãhò€¼ ‚Y˜Án%ÈLü–`¤¿v”› ¢ò/Ó¿ˆÀ"þ›x,¿‰À"ù›ø,Rÿ;€Eö7qXä~$§âo‚äTúMœÊ¿ ’Såâe°¨þ&Hõß© ñ›8,š¿ Ò‘Öo‚T×þMzº¿ ROï‚O³ˆiæà9èfýý§kH%3·ßK Aæÿ;D•¹‹d²tûÃÌõoó¿.Ã?‹Ùþe¶¹ýW<Ç?öÿY‘ ü‡¸ µ`{È-ü…“ó/‹ƒÃï&ØX!3´ø!%A¿›ù‹œÝ!ðwdÊ– DŠÕïxˆÓê¯÷r£~‡@ŠZÿ^mþ@ÈLíþ@ˆæßÕ¸!âìA®®ø!:üFÈ•aùÝ$µ£»ƒù_o•ãQ6À¿‡Ivýᆨvú톤t2s9þ×È9ÙþmýïsBÎäØ€Ò®³;Ø daþÇØØ Ö?fÂQú»+.ˆ"WƒÍÿld2®öf®ÌŽ Rîwq.ˆR7OðnÈ ÷߇RÃr¹]\`—?Û…ŒØã„÷üã(B’zý¾½ÿ@Ȩ|~+„dò¹üKÁÿ}àÄÅÁ^¾Lœ&vÈÆðp°Aî+«ÿ…Ý] #uûûÇòHþ‡-m /*ä"--€a¶m•R%ÓU¯é¡Å­Ú•›f{‘C¿%AÛ¿ÿ¤àL¿Þ¤{_¶÷zÌó‘È5¦ÇOí‹ôi°sbæüóž‡é^¶O'‘îE¶’÷®ÅmèOôî¶¹«#.h•™õ‰ÊT½Ò‘¼³ÑŸEª´’šûð«äPƒ-ƒ9aÜ<ºÒÙöZ‘áM4äê™Î•Qœ‘kž©É¯Ö¦Bl#:VÎÁ=îX÷%…)Ï&Pw@¸ØvñüoíS¶B‘ÙL¼k†’VwkqF„¨æ÷ý,Ôæ9uƒYu±s]ŽKÝ·ËýÓ[]ƒÞPsÛˆæô_ö?*ÒÂOó¹êÃWK£ª¿úÉ/Õ^£„aç [*ÎÊ^.uõ&U$GåĪ_šñ¶¢Óç…Da2”´£-üMútŸMH»%`BpócÍšTÊ…ä òš¾Ÿü0eò/bèqg¬zŽ«þI/˜S8J GNÅÃ;—´E?©w¸¨Hñh?så݉Ûù‹ý°E [¾ÕH+ƒ­:DØcâ-øJO~`“åHU™*Ã\„Vç‰h…؇ŠY5#Ϻäˆ[Fâ‚ô €1³Y?XP8p1†Zü^ Îòê!àqâ\B@‘HÚõR¹{¤ôžÀ, 5è«$ÜFç´ô‘2Lí^=~F>Aý0ï`yæÐDÅ+EK1ñãLøðGß»·ŽKô^ƒ^¯WXäýÊÀ õN?¹U ×ß}z¨ù[²a%épOVWÅ– ÔPÓ†ÚÉõF“UŸØd#}?o‰™  ÈÇ5çÈÚ_âr•_^öÁ1Äœ“Ÿ.1ÐÙn}D–Åì°S¬$<ÎÏ¢áÞu±ªTxó1oö l½'uk.zäzƒ¿H%ô± uÔˆÀ¬ì×oJôù­”B?BÆ'…ÄÜÐ2K—´Hõccï­S\㈳üûð‹k˜€1}OõÈf4€Íº²’Öþ4‡,¡F±C¹&£3¹+l"ëí·ÎQ­ôÊŽý%ŠTy^gŽÐY‹ùsÓ’†±KžœR†íýrU]îu'#k[ßú­e…ÈßbUw’h~Nbg®vÙ¢Fò@[}ñ~Gß?|©‘’œi¨ØLÕåB§ë@ K®U`5 óä C ™X:ȱì~ÙOY$È@dsÒ®§z‡f(úþ 4Ž~BR{&TónöÈì IMô(ÞLç#Ô°ŒãAQɶL'€â†YsxQqÄÔù.ÜKÚ\dÖŒ1@>ì)EÒÊihÍíN«ìÒUņ­×Iœô}áA§p üðÇ&ƒ¶¬Øy÷Ô~í÷"‰‘L½üá?Ÿ½å:d€]A÷xîãœíÅ£žŠ´7iŸàâ dh°R>¡ÝÚi.é 6Þùs9é4 Ô^µÞ;hƬ1çžÏõòhÕÆo\‘jE_}â6hvo,ü 0?Í6'KƒKþCvå 7é€{îCüq=û-Aéꯈµv·‰f}o3X«I™ef鯉ֱï¤rÏQÅÒ`Ùýᇪ¬ví ;½(Pà¥t6·—ÞÁªZ‡•õÃ9žpOMªûñ& á:e={Ü5+Ç;$fÍ ú,ê^ƒ+diÏõh:ƒ%¿·­V_¦=$¢B]¿=h.E…X„ZGÿÌô¨¥e°ËçÈÃ¥‘dà¿;òaò~[™S Ää"ï~-v¯R¾3¨ð--£uÇÊtrL¤u"šš §a*¾}„•#”XÓE 7¼Ü®-¸æÛ¡†z(ðñÐqÂA¹ìVG¯>­hj2üÉ”~k†^Žæ«mÿi–€J±_QŒ8x „!A‹XÎWð…¸aþ 7éË|XÈˉâOL õS±Ç¡}€ªi-‡ãº=ÅWŸ`xàÅ'ÞÜzô–’¸Ek+9‘²ÌO¯9 ÑéZn©Ìñ°ÉŽ9k‹ô|(Å,Ê…Úa8ø¿äêúT4 ÞvgmÌW×]ö&ñZÈŸRœ¢û…§ÛCÄ”‡jˆ}ƒ¥(›ÜÁã} X¯œ‰%–PKÌê)®«Å™ÃÖd^ç”Æ@Is³p§ ×Wޏ÷Õ¥¿ÀìýÁp-«ÞÁVÃì×”X‘¶9 ÙB|Ç΋ª;>5J1àž@âÓó,×Nî§Ñü2éÁØ*·´XÓT$BôW$!•ã£P¿½_Ÿ¼ðdš¥Hî쫯« ¯šì¿žZM7ª¼RÓ6Ê̛űÀåŽ]nÁûÝx§¼š}Ü)pyU`]½¨^âÔÎF‰Ç\¦ôõs_îF“ÇI üÞ© ßÒ*ÏX¶ïÚž®™dÙW—E¬«"¯+ë~ËRÿã9®/™Ìšç!d¦ùˆ±™[ ±…îüœ'¢­ý5#¶=ñ…ÙÞbkxç«3®“³/o>Ú -û|_š«6o°Ô³¾©Å›z5ÑFÏqÔª÷&†¸±pM\~¸÷”"0…ÁÙ¾ïê)Lî_Ws*†V1Ú[Ô|éå2ZkO\c–pï„QAÞü$òy/uèJ-7 ïf3î%ØOü ¼íœ¦Šå¸èËÄcn5Æ”ù{SÓ»_åäµSXãaN'ÌW4UèJ•“U<Ñ  „=åM,g’pþºì|j8ÜÔ£ÀìýžwQ£ 5Æå%³í(\d ú+ÄÂæähcGZ:Y†âøù‰º¬S¦BËfÌÊ»Tf_,>ØB» µK < u„¼5üN´”ʘl~Þœ¿€ù„•Áà’Îß.ÚÏά˜ŠÑcÅðánæNîäÔ-ðÀ€ß.)Mô~ej‘ƒ:ÝÜÔÝ®/IÐèa°%вoʪæ3®~oeGÙþåú®X|ž»€%£ÔJ4’îvU‘×çKdQÜÜLía›`ϽËt1¼!N|l¢wúÊš´¯,lP]EG(PßdH~.C«Rµó ““;V²ëírÿu’žÇÊå_ƒ`Ú†»TMmƒP=zå]Ž“›Qsů"(÷²…;¢#çŒÈ¾gœ7ôJí0úöù•òzz޲Η§Éi[ÂíÈý)Ú¸r¯N2ßd5Wa ô«£Ææs¦¾zwW^l=^h§{ɾWU¶yô…²€—±üìÌ8Ý}Î6º£f Úmìˆ]4‚ÛúÇUÂÅÙÛwhpVp ;¨Iú×ÜGïËÐe9%à‚]ÒCO\Çú2Vú"âN<ûÚœeޏ|­qðøCPxD¦g¼*2¤¿—VhdÕ$…zÏ9Ÿ¥pëŸO‹Щ˜Ÿ=ðÊvë #¿¯šg3ÃÆ CkŽÌLk.²È©µuØû¥'Æ“²³ÈŒ‡¾´ç^_!€îGÜŸÓFþ; ç¶àe@FŸ{ÂÚ©f‰ÞÑ`l¢Âv³Ã,PÕ¿tÅÙüµE=t`}¹Œ¸q»«±ƒaø‘¯A€ð´…:½Ó2(!3އK¤4T$ÉÃT‚jYmôø'´qbJ²W·ÙbEçt¯è„XCg€ÞSjZ[s!nÿR4ËÒÖJ´…5îÅGÚëâ˜#¦F=SÎrcVùy5»V–"»YSc".a!ˆ‚x{¬Æ;÷AVOÅö¥-)0\P)[‘€šî^ò ÛÅxM‡ ü/X‹¸^ü’°c>ŸJVjhøaC£z‘²SÎv¿þ„·õk:›ë eC—WÓ†¹)!iNdQÌÀå>Ù ÂlæHýá°eðþÃŽÞˆ˜=è™®ãÓƒòüÄz|Ÿ Ï(”·àe »ÒòNñÑrVö´†^)¿gSo¹ÑÅ&gÏh»—,>Ïq£Ö=„ª¹ Fb…Æ ßTuÎúê"*%žhª€·>Zµœ/!ícû”µ8ž•ü2Þ«:Aû*9J1£{Ò·óÔŹŸÏ qG&GWŸôvŒ¼á¬®ú<· Âz`ž ÊÍHÉ— Üòs‡ÎSÎ_»ŸYO|[ÿèý .ÛžÇ6Ýî«až|5Ò‚[KüåØõ{OãÂJk¡r"]¤Ç ŒYBâ{þãXàÕgý®ª;sŽô«›¤àn_,K81 ¡G›õûTå_#à" ©ü©è‚¥<ù‡nÞWT9}“×¹³ bQÃëU+àÑ…Ï>Uº=Nåþ&±6Mº‚Å÷fØnß¡Pú" N7×y§aÚ+öÔÛ@x…>‰ïd4“PpvíÿlB¤ê ƒ=µ5@i2¿+Ê ëA¯8ú´PWvÞR‰8\4ÊÞóœƒÛà)o¬l@ˆ¦­ü™™ŸœHj\Î׿Ÿ£zæØÕs¦@Ä=ô"©?¨J\(´· Ô–(äÈÑ] Ê’^ìÈȧ–ü.ìö›º,Öoe„ ÍIúCÖ*[C(È`ÖežS,òŠCfÜ[;u9ŒTmR>“äÒ¢±}b½í~ÿ}JɆÇèž~m¼¯Ëö‰çMaÉ…ùtòØûÌ`|é,éÐ^`"ÆáÍbùêâr¡»+Õ¯¯£·µYçÜ4JK?Á–@ú¨›“/ ¨Ÿ9ÆJ#¥¦® £}–ÖnC^¼;O¥âJËeñ8´_%be¯~{ºwn÷§xÑÎs‚N ¥{ë÷Â⾟労!Qã QD]´ºDÆ 6=¡@ÆÅSQ×v`¦—k:PXHNÝ…¶ù©ïeÂWîã\ÁéMì}vÔ?þÝ„™èÇT„äæ)1/¼’•‡pâéfý] °;'M².ˆÛ€«2~ÆìŸ¯ôAQ’BV ‡nÜN—êm~~ºg!¹; ›9Ì'{žµ1Y²YshÏÏ&ðR7|.HBkvÛh“NÏñZ+ó‘Œ,G*f/)â Ÿå¬èØ¢sÉ0ÀxðÇ,¤Ì’åT rÏx¹L\ƒ–43ÑoTI]gBE]¾Ra~x}=ßîÃ%WRAÔB´Ývq ‘\ïÍe™Nä{v·Ð»ÏuGFàSl£?˜|áÁ E¬ä$¾7EÁż„*¡Â óQ.è*4ˆxåG·¹ CÄ× ¢¦¬ë)gë…já)zŒþ®m4²–É¥{‚23fn–ŲÐÂYûP·e+™Ù7¹lÏ”ãÈäºâæü(´ ô4S?ö9¦O«F¬·èûe¼îò m; qûŽ<Ý–v̽Ӥ¹jµs3®4GèzÊ­?BKÜïe~0 ¯ìÐ,s•ÄðD;ø±ŸÚ]wtŒÊyEt¿ °—"ÕF‘ˆtF ú^¿'W¦XÀHªá-bA†QÁq\dŒI½—Ë ôp:JÇéCxÕôq¼,Öº7£56\±Ö*º,!8C”Ëf§ü'>1ðq% SõýH€Ê §¼Ì³3ú×Ê“»+y"SΙL×§cxâKµrª&1Zc—§¤<èòhʧçÇVó‹-åX»”c•¯Úh’·šb³Ê—‡ûáð®há8[¥¨á˜s|e¾÷í…!\y¹Z“¯6>Õö¼á¨§¤æouÜHõ~šú`þàïî]»È„ŒÿÊTw^ñW;ìD ì”RŸºÊ›ñdŒJ—]}–³ŠqQÓK*z¾å|]õgß­£%Лë6ùLgˆÃÊ“ ^òÏÚÖ½B{G)bUTc¼Ž”O–_1¹{©üª>^×ÿ¾ $ûQòú$&ÃóÇò —=Ù7ûVoaæW-ã”}<‚Ls„ùÇó"E#ËáÐâl+šîíiÄgݤEÊ ê4Gç^àºí­Xˆ´ p= öžŒµ»;¤J< M˜)7'oÃâŸ8rHIÛž@Ì#k»ûî,‰%i³K–ñÜÚ]rîbçJ+.0®'ƒx™îM qô,‡‹Lü«!ÒEÅjÀሚôs:Ä¢1\œ™ò‰€Í³ÄfÃéN½#ø'UÔ¼­—k‡e_ÉÙ¤¬µhY ÉSŬììHÏ+kSVBÕ`‹„ú±Ú¤„o—€#Q½¸YqeJ–#Ç»ˆõ2Þç«UJŽHIYuZ‹—‡àùVNßß®ðF؇¦$+gÍ«,k¸©þŒýh1üÄîöõb\«0 3>ë‡xßÃ^¦¹vNÞ×¾n¦9s«dÛáSÆz¸d½[Š…—8ÄÖMÝë´2žlç 5ª;RÃÊö– &RLpWlºðVéô÷mÑZlzlDSR¸ tQ¿‘¯½uþ<. ‡¯l¬·8WQp÷yê_µ~*%n9ÏËÇÃä7ðóß„'ûðŠIJ,Õ#"3ÉŽå•ÅŠj˜QEŸßŸéýB›F87+Žd™É‹éO¡,žârÛœ»´HЂyZId¥ÿB¬³itøy!Qå²Côäç•*Ý–œ¤-Ô ²šáÜû¨,Kxü]x$öôÜzŠô}Dätï ÍïþU㲨EŠœ›“TŠÚ\žAÖ 0“»£&;WÔjmïo‚7~¡öŸÆš°˜4á‘Fî¸8Yq°¥ ¾Å I}ëÐj8%>cØÐ°þˆÜ/^_#8òRˆŠ¾ðfx]õ‹‰Ù/Rù—ÏjˆXŸæó&M¿„¼2¤ -ûvéß|®Ëì)^05¥¥€ÌO.äø”f熴â‡Â©&¾ëhʇ|GoÎ@kcËÜ` ¶hˆUv2ƒc±RÚ¯T9lºÞŸ_}ù:‘K“ùmÀb³Àl.¿»=÷Ï'¤ÝrGŒoÈE?×OÆzçÓ–DÞÖ!£°Q^fâ»ßz4T_¡’GÃW‰×Ó´û“ºUT&ãΕÌæ–‰T ýÚº"ЩûAb á±MîÝå™Vé´ØÅxÆ yØiŽZ%ý²eÅaã 'iÜÛGq$8g$á Ø³!åˆ#Ë=áÞ¥já1;Ê©…Z±9¤ÓCÞ{.y¾!¼¨F,”÷ò›ª‰N|%ãŠÔé´Ñ7Àq :V»SßJÖFܦ¯-üW¦uÈä´¯BòêhúÌÚn¥ÃÎL,²¨I2 ”­9âÔ¼‰Ï!ô 'piùà\[8(\ïp« ½CM•¼¢Aà K¨<4—Á–ü¾^ªÚ¦‹i¥ Qóí•£=ó[)øcÍ +ß‹ŽüB $ÚS¾i|dÈv ˆïå¡QÝTqß'éô×$xŸ¦5úæ™7«%çkÄ…ú$[â-uü“,ÌÏ6Bí>½‹$üŠhC¤Žõ÷žwÞý¶Å¢‹&Åö‘¼ü×úôïZ#¢“Û$é7eHÚ >–@Ý?u‰ßd7'÷vM›U=’Â|›gDšà}&ñâ9öˆÊjñ~D÷3˜»%la . ²À:ý*cäÔJø=ÊëÁ¯iX>,`d[±WZ[˜7¿x`âãú¢ŸŽí…äMÀ—iÅסq›Î„¸÷Sù +kÛŠ­ˆlùIpZ-£Lc½y¹* ?Ž0p´m Åèìíæ?G ±9Âeä^ï/eX<¾6…ß".i©ÐG°]ŠaðÕVÙ½˜nW§OF ûõpõÔ=¬ h{ZFÕ%FyGúΨ·—陟dE5Ö{òŠqÁ¾´}.çŠâ©êžƒvÕ|—$gG7ÚÞ§¡rý/9Úô„;ƒ°'ïÙ1íÅ?nCN}± t\ïTÏ62Çâ’ìEÜܵÃh]¿šOÅ|ìÀ6V °Ê­û£Ùy⿾Cz:q,%Á®È’y\Q"eÂF ?ÁÂîªèë[w Ô”H^£bz/P$¯zÙ'¨Öžž„jãÕH͇3Ÿña‘½¹šµñn›lVoÕ}­JÙç¢È–Ѭ4–ÃÑ=r¿êÖñ+â&–3~íq‘wËç|SÁß °˜•—xhí:¯œ zæ¦@8 æD“®&öÚV|6µNºá§ç…u‚‡ܥαò ‚7Яd}?>$·PgªãÎ{«rbÜÜ0zÙsö£Ä@A¶zm©Šúdë"F4îŒÛ–B®§¥Ê5Nl[zFÖ—›0*’1Gd/Y¥¸J‘6ç{ã_ÎL¹Võ,”"T–™qN”1„9&ôSDÍbl!”(¹"9mÃ\>“qkçΣúµÓ\·ªŸô]¬ç4~Ä| pÌRîtu:÷kgIÔ¡fXîwb°÷lé©vMÐ6Ï“”’Ÿú ÷í§Þ bå4·±ªkªÏ!áç –wæ4Ëé<…tÈÃpEév¬Âú„…ôr¦’à㇚žç/˜™ÐŒáÓJ/íw8CåüŒ0”WІQšÏމŸŠúŒ²qňì­CI(ÄÞÖ\Ó·4$Ïò£<úÅѸ·êcÊ•f#Âw%òza4Þâ—ð† HÞôû6ø=›ŒûÀ m,g=tZ+ûÙQ*/ÖEÇP£$p–òâTcñ®]PPtS¥Ãd>Ç8Q?pÀ¡F¦—N¤vÐ3Öêלi¼É”9,—gÖ¦RŠ©P|ä2¼hôu¾Ä€ûÕûT¼b‹!ut¶Uç‘• ÎS9ÌOuSC=kíÅË3·gÚÚ£þ/(ZꎚíG¦lª<º‹cJ6;¡—­¤}Îy5P+ù9$ Óqæq4?‘Ÿ.míeŒ’eâÚJCÕž>±Ï·®’H¥µ…¾w ï³}ÜfíÄ }«Už÷x¸Ê`#ÆC§@ß̦k>^T×­Œ*~fšïôÂ@~|zLÎ#ÊŸIÀ˜u™µ çR}?¯”†U[²°N”‹8†ß;á2Ü»tg®ãoØÿÅŒ&Y YèCyš ”:áZÕk/j~t"™|wP}][»Uì'NRdð³™Ç:´üEe¼[ qTøO–×31OÿÝßòv‡í†D† ¨çcKTëiôõĘ"|ž©ä»t³øÄLùGø!ÃÏßëWTûuÂf~mhè¢ÙeÉÇ´ûÕ;·Ñâ{§³/ xLÈõ…:|Fð€£‡Us%`„v”¿-­A¿.ÞH2}Î-ƒê©–{+o4?Q²û™‚í”t¨­UÔÇ8¼O˜[èÆÄT0Dœ<¹FrÂK¾ÚÆWö!ƒ=ÜI»‘šñ/fû'8Ù£‡©Ê£t‘–>±FJôÚ1•wߊ…J#:èeh\2§˜Ä‡£}C5†ÓÉZ½ÎQ~øÒé¨;\íNÅé®Pa•w R²­¾±Õ}<Æ…ó¥×ܼ1!õj•·j&XÀµÀgéÍÔ.Ì*[##OùîQk¼…xÒ»±XÃ.R&ó2ó$8¡ƒö¼§:[— B¤D\=St (ƒÄ¯ iáV†èzùŸ!BÛ3ZQ߯O'…Ù*yø%÷À¼âM×ÿ ý.‚öYy̨ž@ÒY‰r£m6îÙÄ­'CÖFY„Õâ+-öD}cÐT#êCÓs“»þiaÀÉÓ5w® Üg(Êu)Öí¾Î+ËúVG¹löÞ>Eï™'­¨°Ö~žÍ.=ä-Fm~Ù½Ë)è{Ë¥oDÅ](eg4ë3+wþíØW¥f¸C‰0ë,?9ý:çûQ¥íø½¨¡üà»KS®6*”A-Ûnï3eíùrnª>¬Îcô=_6Awâ-ÝnµúrÚä‚Q-Þ\ÅÇÇ.ï@àÕùhèMÅŠÏ$l¸“µ·Õ°t ðŸbWߌåbîrhøÛ›¦;õ”Ý$ëÎ4”¨7çJ6‘fßeºªÖÖË€0Ç×㳪ê½Ú“NÁ䎧–ÄvÈ)’ú×BåJ;åø8‚F«Æ îÔ®‹õª 0k³Ô¬*M.ç®Ôm 5ž6*¹‹øóü÷ öE¿¢ séPlç;ÍGDz$þŽ‘¬8‡øâ˜ºŒ°ŠäÐÒœç‰)¯Fݲ&ÞÂíÂvjðn þ'æ ŽùAèœ<[¹ü¬NdÕÀ×m_ÄÝè±³çMheÚª½ü—”ê‘^Ÿg=—TâWbA½“Š”7ß ¢‰±ÆÄôPI½zKTIxHa4š¥T{k‘D5ä“prMÌxÀwZ‡Øw,ÂÜ\Øè!§ŠÆê³˜ˆº°‹”ݲ“Söte,ë¼$É; ðž˜Ì9!I{QeA3ÍM›íp¤Á—NœùNU|–ÆÂ3ÌڽØÁõ¢öÝnÌlñF4¡†#HÉ’e;<…¤FíÐF +åJm¾â{̘VbÄMs:+Y¦þ—Ë6ÄÚóߢJÍ4²r‚ÙdÕ…ñ{2þORÛÉ;”Ïeh¹ÚœëìLjC\ÊG+÷o–sšÐÖ›ÕíI6ò„Ù9ü?„‘öziêØƒ‰¶uo•>}åoÎD{èNžRì´Ë¥ÇÞØhž‹×*­lç”è˜EdǽâÃo«k¬¨MVïó0'Å C½¦ \\ÎÁΰ賽rõsŽDöGC›OV»ºù±š_óõfÇr{õ5{ÐF .Ì1†’˜S?}ª” icËñ.[%ŒFë&gDÿÚäɈÈ6ek]øPá¶ §oõ¹ëÝ;Ó"6P×RAg ³ºÓ²œ¶$ûËÉ»MgtºÉŽ8±Œ]ïÑ´ºèû C»fêO‰!k0é]樱Ê)ÒkûavÏ6¢ø©x\u𙑧JæÔ¹™Kò²]‹7"’º¯~YÈTæ`×G:|ž1o-ÑÂóÛÙx&iTE0Ó¿Hë¨ýQ;úpè5'祲>l(@OB8¬õ¡ÐÉ¡4íyå4n—GvÞÅkms(m—Eä+áÒÛã ÒœˆK>¸Ǫeæ[BÈVZÙA¯Á/·qFð“äÐ*è#!Cè§áã¤Ò<ä#Xò±ÇŠjk¾ ß×”¿s°ì:GÁVÒ³*N¹ ¹ 2œH=^_ÊèÖJùDåÆP9™ZÑä¿ÚE:Um8,‡ZñJÄx·âïºí‘ùÙÝ´â`•z£ÿ,q¬¡µÀ0ŒÿƒâW|mÇÞÀŠbÞ©›R Ÿ™_Ï'ÿŸñµ)Ë-A%Œ5íÙÃ÷%îñн»O8NçoLdå«ô Ïâ².‹­¹^å¾A­¯m¯ÿ•÷¼Ô+ŠLÆ_vbð0ë9DCð£ì‹n©æž¶¹ÔØ‘ø……“ÅÓ#Y5ÂrÓû©®^Dæ83jP…·MæÕ:3Ï„o¡¥ÇÃJx~ºBCéeߥ¬Ë¼Bî”8#*_%»è* ·”O¨{ÆfÖ',5ää>Ý;á€/ôã;_•À(u¯3_kô.ÿ‘&"mÅ̰Dö©Œ­¼ÆÐuñYî»h«‹qVe^³'ÞkAa˜jå%߯…õç1(ƒw°‰aÙ±k‰wáom±ÄÝÝÖ”fL†7s(KUnæTiÅèÜ)?jšyåÔ¯y7‰•Â>¶1›(2(2‹VùfØzÚ›_ì†YdÑ^" Ø:?­z›·LðVL©`y2G é–ŒŸNœñäPu6TÚþ?BBKb™ipì=SêkB­$|Ü„AmUÞÓ–ø”^-S>ï%úpÑÑ%B„V8Æ|÷¶À˪ ±õõ‰¤‡~ûµ»ÑkD}€™tdÁ3ºæ2Ì KbŸ]ø©QÐÝËL/y÷‡‰Un+ïÄÉ”XŽ"ægÍ™ŽmÇD±>’â—3o.Ö º€«@%Q;Dµ`›ßáÌù:í¨w‘LÅ'·#T˜ŽU¾zJp§*Õ÷Üè …œ¸Ž¼0Ú9ŸJRTFtB”sÖ;üÉ9èk Aò¸ ø&ñÄÁC §~ “Þ$$ ¨,H¤®ü9î NŠfVûј‹óf›Ãzœ% ©Ï5ÁÃE!ÑbŠwìF³†J¢¯;¤ÂÚäq•‹¹»4²ª|¿öǘ òµ¢”š·§ÑÉo<Ä-ÿœÌÂ#ÃsÄsà㨿 e|u,c¹q’O]¡”š$X uº/¶Xo:hA®´C­ö‡ÂkÓØè Z¨S¨GRŒE¸á£ÑسïGû7êJ¨8Ùiϳp•³»Ñ–ðtÃ9¬º¦äµx'';™Y;­}ÖÑL)¢´&ŽgLköu-ÑŒ 雚—Ò„GÍ·:vHvµËD½º¡!Q8iU<†¬Jµã~RÎ0‰Ýû’WWÒò›¹­tf(‹Ž[?§9Ïg3eªAèéð|ÊžÕTõ¥71Åá 9AÑqÍâÆÆ #Õ_šóóà•ùÕ›ÞÌí(ø£¼úCO:·ü4\Ž ]„ØÆcå1kü5²!ÕCYN»ØÇ±AÛírˆv ½{­µ|¹¼6Æ-cKʹ5ªïpÉb6ް1A}ˆ°à±–µ‹†/ßCÙé,,¥ÔèÇ<ÂaD61‰]¥~"VÙeÛÂ(ÓØ&«}Òvä ŠÔî±uŽ=BìBn£úLÆ[îIÕÏÄЪ”ƒÓø”j^[X²u§åÝ¥Å"2íPBtýü#yâKšœ#ã~«ã­™[9)qOËBXyŽ4Ïý™x]òÜ­óJb4ÊTÃIM\œ„Ò·у ¶œ„ 1«ûÄmrcXgÃû,qGç~2õÆ—tïòsUn„¾Q#r<ú§„$¸éD<ØúÄ·ª5;íÀMþoîKzû+‘œS–7´» ç 5 ÁpdßJ¿ IíÅõÿúņ0`@Pfn¢>+ëoê±âTÙüv¿MvÖ[£Ø«ýg ïî3y *j8!#Ô[Q%™¶½wµÁËšÚg~·öž ÑuǺO£åH~Y¨¨ÅCM9¯"ÆénÄhË 4ì<ÀéŽß®ù`Hô,Ô3ûèD}âßt/J J~ç–Tò voy͕ʧhû©Ë8E±ýÇÞ„“Q ö*k2yæK.ÇX&|'޶¡´@Åå×U¸23 VÝ:Cι³QR¬L_Ä7M wFk@WÝsQ‡­)²R§„NùG2£³Fù¯£»ì;>@¯-6¡+kŒüV8(rívÿÙÛçíŽ=†]÷/¯›Vµ*íÆªá“øý§z·›´ÈUÛAãC>„*cöw²Õ-¯,1$~T«Q?Nª34N[®@÷ªùÇ}|ñry xß?.×[fÓ1K±^²Ötu²U‰ãŽo:n¹Ì–·Vˆž'fÚPûÍI]Å|I+¤j¥;OÔ,±œ¶BHJ…ëË\zϾg#ÚDò õV˜”ÐZ”)áÂ&°çÿîSQÄ endstream endobj 97 0 obj << /Type /FontDescriptor /FontName /AMFJPP+CMTT10 /Flags 4 /FontBBox [-4 -235 731 800] /Ascent 611 /CapHeight 611 /Descent -222 /ItalicAngle 0 /StemV 69 /XHeight 431 /CharSet (/A/B/C/D/E/H/I/L/M/N/O/P/R/S/T/U/V/X/Y/a/ampersand/at/b/braceleft/braceright/bracketleft/bracketright/c/colon/comma/d/e/equal/f/g/greater/h/i/k/l/less/m/n/numbersign/o/one/p/parenleft/parenright/period/quotedbl/r/s/semicolon/slash/t/two/u/underscore/v/w/x/y/z/zero) /FontFile 96 0 R >> endobj 29 0 obj << /Type /Font /Subtype /Type1 /BaseFont /YHTLQS+CMBX10 /FontDescriptor 85 0 R /FirstChar 65 /LastChar 123 /Widths 81 0 R >> endobj 31 0 obj << /Type /Font /Subtype /Type1 /BaseFont /ALGQLN+CMBX12 /FontDescriptor 87 0 R /FirstChar 12 /LastChar 121 /Widths 79 0 R >> endobj 30 0 obj << /Type /Font /Subtype /Type1 /BaseFont /HFELHX+CMR10 /FontDescriptor 89 0 R /FirstChar 11 /LastChar 122 /Widths 80 0 R >> endobj 28 0 obj << /Type /Font /Subtype /Type1 /BaseFont /UNXLCG+CMR12 /FontDescriptor 91 0 R /FirstChar 44 /LastChar 119 /Widths 82 0 R >> endobj 27 0 obj << /Type /Font /Subtype /Type1 /BaseFont /RLMIUU+CMR17 /FontDescriptor 93 0 R /FirstChar 50 /LastChar 121 /Widths 83 0 R >> endobj 41 0 obj << /Type /Font /Subtype /Type1 /BaseFont /GFAWRG+CMSY10 /FontDescriptor 95 0 R /FirstChar 15 /LastChar 15 /Widths 78 0 R >> endobj 42 0 obj << /Type /Font /Subtype /Type1 /BaseFont /AMFJPP+CMTT10 /FontDescriptor 97 0 R /FirstChar 34 /LastChar 125 /Widths 77 0 R >> endobj 33 0 obj << /Type /Pages /Count 6 /Parent 98 0 R /Kids [22 0 R 38 0 R 48 0 R 58 0 R 62 0 R 66 0 R] >> endobj 76 0 obj << /Type /Pages /Count 1 /Parent 98 0 R /Kids [72 0 R] >> endobj 98 0 obj << /Type /Pages /Count 7 /Kids [33 0 R 76 0 R] >> endobj 99 0 obj << /Type /Outlines /First 7 0 R /Last 19 0 R /Count 3 >> endobj 19 0 obj << /Title 20 0 R /A 17 0 R /Parent 99 0 R /Prev 11 0 R >> endobj 15 0 obj << /Title 16 0 R /A 13 0 R /Parent 11 0 R >> endobj 11 0 obj << /Title 12 0 R /A 9 0 R /Parent 99 0 R /Prev 7 0 R /Next 19 0 R /First 15 0 R /Last 15 0 R /Count -1 >> endobj 7 0 obj << /Title 8 0 R /A 5 0 R /Parent 99 0 R /Next 11 0 R >> endobj 100 0 obj << /Names [(Doc-Start) 26 0 R (page.1) 25 0 R (page.2) 40 0 R (page.3) 50 0 R (page.4) 60 0 R (page.5) 64 0 R] /Limits [(Doc-Start) (page.5)] >> endobj 101 0 obj << /Names [(page.6) 68 0 R (page.7) 74 0 R (section*.1) 32 0 R (section.1) 6 0 R (section.2) 10 0 R (section.3) 18 0 R] /Limits [(page.6) (section.3)] >> endobj 102 0 obj << /Names [(section.4) 75 0 R (subsection.2.1) 14 0 R (subsection.3.1) 69 0 R (subsection.3.2) 70 0 R] /Limits [(section.4) (subsection.3.2)] >> endobj 103 0 obj << /Kids [100 0 R 101 0 R 102 0 R] /Limits [(Doc-Start) (subsection.3.2)] >> endobj 104 0 obj << /Dests 103 0 R >> endobj 105 0 obj << /Type /Catalog /Pages 98 0 R /Outlines 99 0 R /Names 104 0 R /PageMode/UseOutlines /OpenAction 21 0 R >> endobj 106 0 obj << /Author()/Title()/Subject()/Creator(LaTeX with hyperref package)/Producer(pdfTeX-1.40.3)/Keywords() /CreationDate (D:20071114151804+11'00') /ModDate (D:20071114151804+11'00') /Trapped /False /PTEX.Fullbanner (This is pdfTeX, Version 3.141592-1.40.3-2.2 (Web2C 7.5.6) kpathsea version 3.5.6) >> endobj xref 0 107 0000000001 65535 f 0000000002 00000 f 0000000003 00000 f 0000000004 00000 f 0000000000 00000 f 0000000015 00000 n 0000003774 00000 n 0000071524 00000 n 0000000060 00000 n 0000000090 00000 n 0000003833 00000 n 0000071402 00000 n 0000000135 00000 n 0000000164 00000 n 0000006699 00000 n 0000071341 00000 n 0000000215 00000 n 0000000277 00000 n 0000012001 00000 n 0000071267 00000 n 0000000323 00000 n 0000000356 00000 n 0000000980 00000 n 0000001268 00000 n 0000000406 00000 n 0000001088 00000 n 0000001148 00000 n 0000070524 00000 n 0000070384 00000 n 0000069962 00000 n 0000070244 00000 n 0000070103 00000 n 0000001208 00000 n 0000070945 00000 n 0000003025 00000 n 0000003202 00000 n 0000003385 00000 n 0000003893 00000 n 0000002877 00000 n 0000001385 00000 n 0000003714 00000 n 0000070664 00000 n 0000070804 00000 n 0000003549 00000 n 0000006109 00000 n 0000006286 00000 n 0000006462 00000 n 0000006759 00000 n 0000005968 00000 n 0000003998 00000 n 0000006639 00000 n 0000009424 00000 n 0000009600 00000 n 0000009777 00000 n 0000009954 00000 n 0000010131 00000 n 0000010308 00000 n 0000010545 00000 n 0000009262 00000 n 0000006876 00000 n 0000010485 00000 n 0000012061 00000 n 0000011833 00000 n 0000010638 00000 n 0000011941 00000 n 0000014133 00000 n 0000013846 00000 n 0000012154 00000 n 0000013954 00000 n 0000014014 00000 n 0000014073 00000 n 0000015916 00000 n 0000015688 00000 n 0000014226 00000 n 0000015796 00000 n 0000015856 00000 n 0000071054 00000 n 0000016021 00000 n 0000016407 00000 n 0000016429 00000 n 0000017065 00000 n 0000017687 00000 n 0000018045 00000 n 0000018462 00000 n 0000018908 00000 n 0000022452 00000 n 0000022691 00000 n 0000029248 00000 n 0000029552 00000 n 0000043848 00000 n 0000044278 00000 n 0000050351 00000 n 0000050630 00000 n 0000055793 00000 n 0000056063 00000 n 0000057269 00000 n 0000057494 00000 n 0000069484 00000 n 0000071128 00000 n 0000071194 00000 n 0000071595 00000 n 0000071757 00000 n 0000071928 00000 n 0000072090 00000 n 0000072184 00000 n 0000072222 00000 n 0000072347 00000 n trailer << /Size 107 /Root 105 0 R /Info 106 0 R /ID [ ] >> startxref 72661 %%EOF python-casacore-2.2.1/doc/Makefile000066400000000000000000000044771320311315100170220ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d .build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf .build/* html: mkdir -p .build/html .build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) .build/html @echo @echo "Build finished. The HTML pages are in .build/html." pickle: mkdir -p .build/pickle .build/doctrees $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) .build/pickle @echo @echo "Build finished; now you can process the pickle files." web: pickle json: mkdir -p .build/json .build/doctrees $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) .build/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: mkdir -p .build/htmlhelp .build/doctrees $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) .build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in .build/htmlhelp." latex: mkdir -p .build/latex .build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) .build/latex @echo @echo "Build finished; the LaTeX files are in .build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p .build/changes .build/doctrees $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) .build/changes @echo @echo "The overview file is in .build/changes." linkcheck: mkdir -p .build/linkcheck .build/doctrees $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) .build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in .build/linkcheck/output.txt." python-casacore-2.2.1/doc/casacore.tex000066400000000000000000000262601320311315100176560ustar00rootroot00000000000000\section{Introduction} Since long glish bindings to the \href{http://casacore.googlecode.com}{casacore} system have been in place. Quite recently Python bindings have been created in the general casapy framework using tools like CCMTools, Xerces, Xalan, and IDL. Albeit very flexible, it is quite complicated and it is not straightforward to build on other systems than RedHat and OS-X. Therefore an attempt has been made to make a simpler Python binding using \href{http://www.boost.org/libs/python/doc}{Boost.Python}. This proved to be very easy and succesful. The binding consists of two parts: \begin{itemize} \item Converters to translate objects between Python and C++. \item Class wrappers to map a C++ class and its functions to Python. \end{itemize} The Python numarray and numpy (version 1.0 or higher) packages are supported. At build time one can choose which ones should be used. \section{Converters} Boost.Python offers a nice way to convert objects to and from Python. Ralf W. Grosse-Kunstleve {\tt} of \href{http://www.lbl.gov}{Lawrence Berkeley National Laboratory} has built converters for standard STL containers. This has been extended to convert to/from other objects. \\The following C++ objects are currently supported: \begin{itemize} \item scalars (bool, integer, real, complex) \item \texttt{std::string} \item \texttt{casa::String} \item \texttt{std::vector} \item \texttt{casa::Vector} \item \texttt{casa::IPosition} which defines an array's shape or index. \item \texttt{casa::Record} which is a \tt{dict}-like object. \item \texttt{casa::ValueHolder} which is a kind of \tt{any} object holding a scalar, casa::Array or casa::Record. \item exceptions (\texttt{casa::IterError} and \texttt{std::exception}) \end{itemize} These C++ objects can usually be created from several types of Python objects and are converted to a specific Python object. \\Note that the all kinds of numpy (and numarray) objects are handled by the converters. These are: \begin{itemize} \item An array is an N-dimensional (N>0) array of a given type (bool, int, float, complex, string). \item A scalar array is a 0-dimensional array constructed like \tt{numpy.array(value)}. Such an array cannot be indexed in Python. \item An array scalar is an element from an array. The converters treat them as normal scalars, which very few Python bindings do. \end{itemize} The C++ objects map in the following way to Python objects. \begin{itemize} \item A vector or IPosition object is converted to a Python list. \\It can be constructed from the following Python objects: \begin{itemize} \item scalar \item list or tuple \item numarray scalar array or 1-dim array \item numpy scalar array or 1-dim array \end{itemize} Note that a list or tuple of arbitrary objects can be given. For example, it is possible to get a \texttt{Vector} from Python. \item A casa::Record is mapped to a Python dict. \item Every C++ exception is mapped to a Python \texttt{RunTimeError} exception. However, \texttt{casa::IterError} is special and is mapped to an end-of-iteration exception (\texttt{StopIteration}) in Python. \item A casa::ValueHolder is a special \href{http://casacore.googlecode.com}{casacore} object that can hold a record or a scalar value or N-dim array of many types (bool, numeric, string). It is meant to conceal the actual type which is useful in functions that can accept a variety of types (like \texttt{getcell} in the table binding). \\Converting a ValueHolder to Python creates the appropriate Python scalar, array, or dict object. When converting from Python to ValueHolder, the appropriate internal ValueHolder value is constructed; a list, tuple, and array object are converted to an \href{http://casacore.googlecode.com}{casacore} array in the ValueHolder. \end{itemize} It means there is no direct Array conversion to/from Python. A ValueHolder object is always needed to do the conversion. Note that this is a cheap operation, as it uses Array reference semantics. ValueHolder has functions to convert between types, so one can get out an Array with the required type. \subsection{Array conversion to/from numpy and numarray} \href{http://casacore.googlecode.com}{casacore} arrays are kept in Fortran-order, while Python arrays are kept in C-order. It was felt that the Python interface should be as pythonic as possible. Therefore it was decided that the array axes are reversed when converting to/from Python. The values in an IPosition object (describing shape or position) are also reversed when converting to/from Python. \\Note that although numarray and numpy have Fortran-array provisions by setting the appropriate internal strides, they do not really support them. When adding, for instance, the scalar value 0 to a Fortran-array, the result is a transposed version of the original (which can be a quite expensive operation). Also operating on a Fortran-array is twice as slow as operating on a C-array. A function binding could be such that shape information is passed via, say, a \texttt{Record} and not via an \texttt{IPosition} object. In that case its values are not reversed automatically, so the programmer is responsible for doing it. An \href{http://casacore.googlecode.com}{casacore} array is returned to Python as an array object containing a copy of the \href{http://casacore.googlecode.com}{casacore} array data. If pyrap has been built with support for only one Python array package (numpy or numarray), it is clear which array type is returned. If support for both packages has been built in, by default an array of the imported package is returned. If both or no array packages have been imported, a numpy array is returned. \\Note that there is no support for the old Numeric package. An \href{http://casacore.googlecode.com}{casacore} array constructed from a Python array is regarded as a temporary object. So if possible, the \href{http://casacore.googlecode.com}{casacore} array refers to the Python array data to avoid a needless copy. This is not possible if the element size in Python differs from \href{http://casacore.googlecode.com}{casacore}. It is also not possible if the Python array is not contiguous (or not aligned or byte swapped). In those cases a copy is made. A few more numarray/numpy specific issues are dealt with: \begin{itemize} \item An empty N-dim \href{http://casacore.googlecode.com}{casacore} array (i.e. an array containing no elements) is returned as an empty N-dim Python array. If the dimensionality is zero, it is returned as an empty 1-dim array, to prevent numarray/numpy from treating it as a scalar value. \item In numarray \texttt{array()} results in \texttt{Py\_None}. This is accepted by the converters as an empty 1-dim array. \item Empty arrays can be constructed in Python using empty lists. For example, \texttt{array([[]])} results in an empty 2-dim array. The converters accept such empty N-dim Python arrays. The type of an empty array is set to Int by numarray and to Double by numpy. \item Because the type of an empty Python array cannot easily be set, the converters can convert an empty integer or real array to any type. \item The converters accept a numpy string array. However, it is returned to Python as the special \texttt{dict} object described above. \item Numpy array scalars (elements in an array) are treated by the converters as ordinary scalar values. \end{itemize} \section{Class wrappers} Usually a binding to an existing Proxy class is made, for example \texttt{TableProxy}, which should be the same class used in the glish-binding. For a simple binding, only some simple C++ code has to be written in pyrap\_xx/src/pyxx.cc, where XX is the name of the package/class. \begin{verbatim} // Include files for converters being used. #include #include #include // Include file for boost python. #include using namespace boost::python; namespace casa { namespace pyrap { void wrap_xx() { // Define the class; "xx" is the class name in Python. class_ ("xx") // Define the constructor. // Multiple constructors can be defined. // They have to have different number of arguments. .def (init<>()) // Add a .def line for each function to be wrapped. // An arg line should be added for each argument giving // its name and possibly default value. .def ("func1", &XX::func1, (boost::python::arg("arg1"), boost::python::arg("arg2")=0)) ; } }} BOOST_PYTHON_MODULE(_xx) { // Register the conversion functions. casa::pyrap::register_convert_excp(); casa::pyrap::register_convert_basicdata(); casa::pyrap::register_convert_casa_record(); // Initialize the wrapping. casa::pyrap::wrap_xx(); } \end{verbatim} Python requires for each package a file \texttt{\_\_init\_\_.py}, so such an empty file should be created as well. \subsection{More complicated wrappers} Sometimes a C++ function cannot be wrapped directly, because the argument order needs to be changed or because some extra Python checks are necessary. In such a case the class needs to be implemented in Python itself. \\The C++ wrapped class name needs to get a different name, usually by preceeding it with an underscore like: \begin{verbatim} class_ ("_xx") \end{verbatim} The Python class should be derived from it and implement the constructor by calling the constructor of \_xx. \begin{verbatim} class xx(_xx): def __init__(self): _xx.__init__(self) \end{verbatim} Now \texttt{xx} inherits all functions from \texttt{\_xx}. The required function can be written in Python like \begin{verbatim} def func1 (self, arg1, arg2): return self._func1 (arg2, arg1); \end{verbatim} Note that in the wrapper the function name also needs to be preceeded by an underscore to make it different. \subsection{Combining multiple classes} Sometimes one wants to combine multiple classes in a package. A example is package \texttt{pyrap\_tables} which contains the classes \texttt{table}, \texttt{tablecolumn}, \texttt{tablerow}, \texttt{tableiter}, and \texttt{tableindex}. One is referred to the code of this package to see how to do it. \section{Python specifics} Besides an array being in C-order, there are a few more Python specific issues. \begin{itemize} \item Indexing starts at 0 (vs. 1 in glish). \item The end value in a range like \texttt{[10:20]} is exclusive (vs. inclusive in glish). Furthermore Python supports a step and reversed ranges. \item Where useful, the function \texttt{\_\_str\_\_} should be added giving the name of the object. This function is used when printing an object. \item Where useful, the functions \texttt{\_\_len\_\_}, \texttt{\_\_setitem\_\_(index, value)}, and \texttt{\_\_getitem\_\_(index)} should be added to make it possible that a user indexes an object directly like \texttt{tabcol[i]} or \texttt{tabcol[start:stop:step]}. \item When these functions are added, Python supports iteration in an object. Explicit iteration can also be done by adding the functions \texttt{\_\_iter\_\_} and \texttt{next}. At the end \texttt{next} should raise the Python \texttt{StopIteration} exception (or throw \texttt{casa::IterError} when implemented in C++) to stop the iteration. \end{itemize} python-casacore-2.2.1/doc/casacore_fitting.rst000066400000000000000000000003331320311315100214030ustar00rootroot00000000000000=========================== Module :mod:`fitting` =========================== .. automodule:: casacore.fitting API --- .. autoclass:: casacore.fitting.fitserver :members: :undoc-members: :inherited-members: python-casacore-2.2.1/doc/casacore_functionals.rst000066400000000000000000000032561320311315100222730ustar00rootroot00000000000000========================= Module :mod:`functionals` ========================= .. automodule:: casacore.functionals Class :class:`functionals.functional` ------------------------------------- .. autoclass:: casacore.functionals.functional :members: Class :class:`functionals.gaussian1d` ------------------------------------- .. autoclass:: casacore.functionals.gaussian1d :members: :inherited-members: Class :class:`functionals.gaussian2d` ------------------------------------- .. autoclass:: casacore.functionals.gaussian2d :members: :inherited-members: Class :class:`functionals.poly` ------------------------------------- .. autoclass:: casacore.functionals.poly :members: :inherited-members: Class :class:`functionals.oddpoly` ------------------------------------- .. autoclass:: casacore.functionals.oddpoly :members: :inherited-members: Class :class:`functionals.evenpoly` ------------------------------------- .. autoclass:: casacore.functionals.evenpoly :members: :inherited-members: Class :class:`functionals.chebyshev` ------------------------------------- .. autoclass:: casacore.functionals.chebyshev :members: :inherited-members: Class :class:`functionals.compound` ------------------------------------- .. autoclass:: casacore.functionals.compound :members: :inherited-members: Class :class:`functionals.combi` ------------------------------------- .. autoclass:: casacore.functionals.combi :members: :inherited-members: Class :class:`functionals.compiled` ------------------------------------- .. autoclass:: casacore.functionals.compiled :members: :inherited-members: python-casacore-2.2.1/doc/casacore_images.rst000066400000000000000000000034261320311315100212120ustar00rootroot00000000000000==================== Module :mod:`images` ==================== .. automodule:: casacore.images Class :class:`images.image` --------------------------- .. autoclass:: casacore.images.image :members: :undoc-members: :inherited-members: ========================= Module :mod:`coordinates` ========================= .. automodule:: casacore.images.coordinates :members: :undoc-members: Class :class:`images.coordinates.coordinatesystem` -------------------------------------------------- .. autoclass:: casacore.images.coordinates.coordinatesystem :members: :undoc-members: :inherited-members: Class :class:`images.coordinates.coordinate` -------------------------------------------- .. autoclass:: casacore.images.coordinates.coordinate :members: :undoc-members: :inherited-members: Class :class:`images.coordinates.directioncoordinate` ----------------------------------------------------- .. autoclass:: casacore.images.coordinates.directioncoordinate :members: :undoc-members: Class :class:`images.coordinates.spectralcoordinate` ---------------------------------------------------- .. autoclass:: casacore.images.coordinates.spectralcoordinate :members: :undoc-members: Class :class:`images.coordinates.linearcoordinate` -------------------------------------------------- .. autoclass:: casacore.images.coordinates.linearcoordinate :members: :undoc-members: Class :class:`images.coordinates.stokescoordinate` -------------------------------------------------- .. autoclass:: casacore.images.coordinates.stokescoordinate :members: :undoc-members: Class :class:`images.coordinates.tabularcoordinate` --------------------------------------------------- .. autoclass:: casacore.images.coordinates.tabularcoordinate :members: :undoc-members: python-casacore-2.2.1/doc/casacore_measures.rst000066400000000000000000000121161320311315100215650ustar00rootroot00000000000000=============================== Module :mod:`casacore.measures` =============================== .. module:: casacore.measures Introduction ============ This is a python binding to `casacore measures <../../casacore/doc/html/group__Measures__module.html>`_ A measure is a quantity with a specified reference frame (e.g. *UTC*, *J2000*, *mars*). The measures module provides an interface to the handling of measures. The basic functionality provided is: * Conversion of measures, especially between different frames (e.g. *UTC* to *LAST*) * Calculation of e.g. a rest frequency from a velocity and a frequency. To access the measures do the following. We will use `dm` as the measures instance through all examples:: >>> from casacore.measures import measures >>> dm = measures() Measures -------- Measures are e.g. an epoch or coordinates which have in addition to values - :class:`casacore.quanta.Quantity` - also a reference specification and possibly an offset. They are represented as records with fields describing the various entities embodied in the measure. These entities can be obtained by the access methods: * :meth:`~casacore.measures.measures.get_type` * :meth:`~casacore.measures.measures.get_ref` * :meth:`~casacore.measures.measures.get_offset` * :meth:`~casacore.measures.measures.get_value`. Each measure has its own list of reference codes (see the individual methods for creating them, like :meth:`~casacore.measures.measures.direction`). If an empty or no code reference code is given, the default code for that type of measure will be used (e.g. it is *J2000* for a :meth:`~casacore.measures.measures.direction`). If an unknown code is given, this default is also returned, but with a warning message. The values of a measure (like the right-ascension for a :meth:`~casacore.measures.measures.direction`) are given as :func:`casacore.quanta.quantity`. Each of them can be either a scalar quantity with a scalar or vector for its actual value (see the following example):: >>> from casacore.quanta import quantity >>> dm.epoch('utc','today') # note that your value will be different {'m0': {'unit': 'd', 'value': 55147.912709756973}, 'refer': 'UTC', 'type': 'epoch'} >>> dm.direction('j2000','5h20m','-30.2deg') {'m0': {'unit': 'rad', 'value': 1.3962634015954634}, 'm1': {'unit': 'rad', 'value': -0.52708943410228748}, 'refer': 'J2000', 'type': 'direction'} >>> a = dm.direction('j2000','5h20m','-30.2deg') >>> print a['type'] direction >>> dm.get_offset(a) None >>> dm.getref(a) J2000 >>> dm.get_value(a) [1.3962634016 rad, -0.527089434102 rad] >>> dm.get_value(a)[0] 1.3962634016 rad >>> dm.get_value(a)[1] -0.527089434102 rad >>> # try as a scalar quantity with multiple values >>> a = dm.direction('j2000', quantity([10,20],'deg'), quantity([30,40], 'deg')) >>> dm.get_value(a)[0] [0.17453292519943295, 0.3490658503988659] rad >>> dm.get_value(a)[0].get_value()[1] 0.3490658503988659 >>> print a {'m0': {'unit': 'rad', 'value': array([ 0.17453293, 0.34906585])}, 'm1': {'unit': 'rad', 'value': array([ 0.52359878, 0.6981317 ])}, 'refer': 'J2000', 'type': 'direction'} Known measures are: * :meth:`~casacore.measures.measures.epoch`: an instance in time (internally expressed as MJD or MGSD) * :meth:`~casacore.measures.measures.direction`: a direction towards an astronomical object (including planets, sun, moon) * :meth:`~casacore.measures.measures.position`: a position on Earth * :meth:`~casacore.measures.measures.frequency`: electromagnetic wave energy * :meth:`~casacore.measures.measures.radialvelocity`: radial velocity of astronomical object * :meth:`~casacore.measures.measures.doppler`: doppler shift (i.e. radial velocity in non-velocity units like *Optical*, *Radio*. * :meth:`~casacore.measures.measures.baseline`: interferometer baseline * :meth:`~casacore.measures.measures.uvw`: UVW coordinates * :meth:`~casacore.measures.measures.earthmagnetic`: Earth' magnetic field In addition to the reference code (like *J2000*), a measure needs sometimes more information to be convertable to another reference code (e.g. a time and position to convert it to an azimuth/elevation). This additional information is called the reference frame, and can specify one or more of 'where am i', 'when is it', 'what direction", 'how fast'. The frame values can be set using the method :meth:`measures.do_frame`. Since you would normally work from a fixed position, the position frame element ('where you are'), can be specified in your .aipsrc if its name is in the Observatory list (obslist) tool function. You can set your preferred position by adding to your *.casarc* file:: measures.default.observatory: atca API --- .. autofunction:: casacore.measures.is_measure .. autoclass:: casacore.measures.measures :members: :exclude-members: asbaseline, doframe, framenow, getvalue, todop, todoppler, torestfrequency, torest, touvw, tofrequency, toradialvelocity python-casacore-2.2.1/doc/casacore_quanta.rst000066400000000000000000000171721320311315100212410ustar00rootroot00000000000000============================= Module :mod:`casacore.quanta` ============================= .. module:: casacore.quanta Python bindings for `casacore Quantum objects <../../casacore/doc/html/classcasa_1_1Quantum.html>`_ It transparently handles Quantity and Quantum >. Introduction ============ A quantity is a value with a unit. For example, '5km/s', or '20Jy/pc2'. This module enables you to create and manipulate such quantities. The types of functionality provided are: * Conversion of quantities to different units * Calculations with quantities Constants, time and angle formatting ------------------------------------ If you would like to see all the possible constants known to quanta you can execute the function :func:`casacore.quanta.constants.keys()`. You can get the value of any constant in that dictionary with a command such as:: >>> from casacore import quanta >>> boltzmann = quanta.constants['k'] >>> print 'Boltzmann constant is ', boltzmann Boltzmann constant is 1.3806578e-23 J/K There are some extra handy ways you can manipulate strings when you are dealing with times or angles. The following list shows special strings and string formats which you can input to the quantity function. Something in square brackets is optional. There are examples after the list. * time: [+-]hh:mm:ss.t... - This is the preferred time format (trailing fields can be omitted) * time: [+-]hhHmmMss.t..[S] - This is an alternative time format (HMS case insensitive, trailing second fields can be omitted) * angle: [+-]dd.mm.ss.t.. - This is the preferred angle format (trailing fields after second priod can be omitted; dd.. is valid) * angle: [+-]ddDmmMss.t...[S] - This is an alternative angle format (DMS case insensitive, trailing fields can be omitted after M) * today - The special string "today" gives the UTC time at the instant the command was issued. * today/time - The special string "today" plus the specified time string gives the UTC time at the specified instant * yyyy/mm/dd[/time] - gives the UTC time at the specified instant * yyyy-mm-dd[Ttime[+-hh[:mm]]] - gives the UTC time from ISO 8601 format with timezone offset * dd[-]mmm[-][cc]yy[/time] - gives the UTC time at the specified instant in calendar style notation (23-jun-1999) All possible units are visible in the dict `casacore.quanta.constants.units`, and all possible prefixes (all SI prefixes) are in the dict `casacore.quanta.constants.prefixes`. Note that the standard unit for degrees is 'deg', and for days 'd'. Formatting is done in such a way that it interprets a 'd' as degrees if preceded by a value without a period and if any value following it is terminated with an 'm'. In other cases 'days' are assumed. Here are some examples:: >>> from casacore.quanta import quantity >>> print quantity('today') 50611.2108 d >>> print quantity('5jul1998') 50999 unit=d print quantity('5jul1998/12:') 50999.5 d >>> print quantity('-30.12.2') 30.2005556 deg >>> print quantity('2:2:10') 30.5416667 deg >>> print quantity('23h3m2.2s') 345.759167 deg Python :mod:`datetime` to quantity:: >>> import datetime >>> utcnow = datetime.datetime.utcnow() >>> q = quantity(utcnow.isoformat()) The (string) output of quantities can be controlled in different ways: Standard output: >>> q = quantity('23h3m2.2s') >>> print q 345.75917 deg Angle/time quantity formatting: >>> print q.formatted("ANGLE") +345.45.33 Precision formatting: >>> print q.to_string("%0.2f") 345.76 deg API === .. function:: is_quantity(q) :param q: the object to check. .. function:: quantity(*args) A Factory function to create a :class:`casacore.quanta.Quantity` instance. This can be from a scalar or vector and a unit. :param args: * A string will be parsed into a :class:`casacore.quanta.Quantity` * A `dict` with the keys `value` and `unit` * two arguments representing `value` and `unit` Examples:: q1 = quantity(1.0, "km/s") q2 = quantity("1km/s") q3 = quantity([1.0,2.0], "km/s") .. class:: Quantity A unit-value based physical quantity. .. method:: set_value(val) Set the value of the quantity :param val: The new value to change to (in current units) .. method:: get(unit=None) Return the quantity as another (conformant) one. :param unit: an optional conformant unit to convert the quantity to. If the unit isn't specified the canonical unit is used. :rtype: :class:`casacore.quanta.Quantity` Example:: >>> q = quantity('1km/s') >>> print q.get('m/s') 1000.0 m/s .. method:: get_value(unit) Get the value of the quantity suing the optiona unit :param unit: a conformant unit to convert the quantity to. :rtype: `float` ot `list` of `float` Example:: >>> q = quantity('1km/s') >>> print q.get_value() 1.0 .. method:: get_unit() Retrieve the unit :rtype: string .. method:: conforms(other) Check if another :class:`casacore.quanta.Quantity` conforms to self. :param other: an :class:`casacore.quanta.Quantity` object to compare to .. method:: convert(other=None) Convert the quantity using the given :class:`Quantity` or unit string. :param other: an optional conformant :class:`Quantity` to convert to. If other isn't specified the canonical unit is used. Example:: >>> q = quantity('1km/s') >>> q.convert() >>> print q 1000.0 m/s .. method:: to_dict() Return self as a python :class:`dict` with `value` and `unit` keys. :rtype: :class:`dict` .. method:: to_angle() Convert to an angle Quantity. This will only work if it conforms to angle :rtype: :class:`casacore.quanta.Quantity` .. method:: to_time() Convert to a time Quantity (e.g. hour angle). This will only work if it conforms to time :rtype: :class:`casacore.quanta.Quantity` .. method:: to_unix_time() Convert to a unix time value (in seconds). This can be used to create python :class:`datetime.datetime` objects :rtype: float .. method:: to_string(fmt="%0.5f") Return a string with the Quantity values' precision formatted with `fmt`. :param fmt: the printf type formatting string. :rtype: string .. method:: formatted(fmt) Return a formatted string representation of the Quantity. :param fmt: the format code for angle or time formatting as per `casacore angle format <../../casacore/doc/html/classcasa_1_1MVAngle.html#ef9ddd9c3fe111aef61b066b2745ced4>`_ and `casacore time format <../../casacore/doc/html/classcasa_1_1MVTime.html#906c0740cdae7a50ef933d6c3e2ac5ab>`_ :rtype: string On top of the listed method, it also supports all mathematical operators and functions like: * \*, \*=, +, +=, -, -=, /, /= * <, <=, >, >=, ==, != * abs, pow, root, srqt, cels, floor, sin, cos, asin, acos, atan, atan2 log, log10, exp * near and nearabs Examples:: >>> q = quantity("1km/s") >>> print q*2 2.0 km/s >>> print 2*q 2.0 km/s >>> q /= 2 >>> print q 0.5 km/s >>> q2 = quantity("0rad") >>> print dq.cos(q) 1.0 python-casacore-2.2.1/doc/casacore_tables.rst000066400000000000000000000064701320311315100212210ustar00rootroot00000000000000==================== Module :mod:`tables` ==================== .. automodule:: casacore.tables Table utility functions ----------------------- :func:`taql` or `tablecommand()` Execute TaQL query command :func:`tablefromascii` Create table from ASCII file :func:`maketabdesc` or `tablecreatedesc` Create table description :func:`makescacoldesc` or `tablecreatescalarcoldesc` Create description of column holding scalars :func:`makearrcoldesc` or `tablecreatearraycoldesc` Create description of column holding arrays :func:`makecoldesc` Create description of any column :func:`tabledefinehypercolumn` Advanced definition of hypercolumn for tiled storage managers :func:`tableexists` Test if a table exists :func:`tableiswritable` Test if a table is writable :func:`tablecopy` Copy a table :func:`tabledelete` Delete a table :func:`tablerename` Rename a table :func:`tableinfo` Get the type info of a table :func:`tablesummary` Get a summary of the table MeasurementSet utility functions -------------------------------- :func:`addImagingColumns` Add MeasurementSet columns needed for the CASA imager :func:`removeImagingColumns` Remove CASA imager columns CORRECTED_DATA, MODEL_DATA, and IMAGING_WEIGHT :func:`addDerivedMSCal` Add the DerivedMSCal virtual columns like PA1, HA1 to a MeasurementSet :func:`removeDerivedMSCal` Remove the DerivedMSCal virtual columns like PA1, HA1 from a MeasurementSet :func:`msconcat` Concatenate spectral windows in different MSs to a single MS (in a virtual way) Utility functions details ------------------------- .. autofunction:: casacore.tables.taql .. autofunction:: casacore.tables.tablefromascii .. autofunction:: casacore.tables.maketabdesc .. autofunction:: casacore.tables.makescacoldesc .. autofunction:: casacore.tables.makearrcoldesc .. autofunction:: casacore.tables.makecoldesc .. autofunction:: casacore.tables.tabledefinehypercolumn .. autofunction:: casacore.tables.tableexists .. autofunction:: casacore.tables.tableiswritable .. autofunction:: casacore.tables.tablecopy .. autofunction:: casacore.tables.tabledelete .. autofunction:: casacore.tables.tablerename .. autofunction:: casacore.tables.tableinfo .. autofunction:: casacore.tables.tablesummary .. autofunction:: casacore.tables.addImagingColumns .. autofunction:: casacore.tables.removeImagingColumns .. autofunction:: casacore.tables.addDerivedMSCal .. autofunction:: casacore.tables.removeDerivedMSCal .. autofunction:: casacore.tables.msconcat Class :class:`tables.table` --------------------------- .. autoclass:: casacore.tables.table :members: :undoc-members: :inherited-members: Class :class:`tables.tablecolumn` --------------------------------- .. autoclass:: casacore.tables.tablecolumn :members: :undoc-members: :inherited-members: Class :class:`tables.tablerow` ------------------------------ .. autoclass:: casacore.tables.tablerow :members: :undoc-members: :inherited-members: Class :class:`tables.tableiter` ------------------------------- .. autoclass:: casacore.tables.tableiter :members: :undoc-members: :inherited-members: Class :class:`tables.tableindex` -------------------------------- .. autoclass:: casacore.tables.tableindex :members: :undoc-members: :inherited-members: .. automodule:: casacore.tables.tableutil .. automodule:: casacore.tables.msutil python-casacore-2.2.1/doc/casacore_util.rst000066400000000000000000000007331320311315100207200ustar00rootroot00000000000000=========================== Module :mod:`casacore.util` =========================== General utility functions for casacore modules ---------------------------------------------- .. automodule:: casacore.util :func:`~casacore.util.getlocals` Get local python variables :func:`~casacore.util.substitute` Substitute global python variables in a command string Description ----------- .. autofunction:: casacore.util.getlocals .. autofunction:: casacore.util.substitute python-casacore-2.2.1/doc/conf.py000066400000000000000000000135651320311315100166570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # pyrap documentation build configuration file, created by # sphinx-quickstart on Tue Jan 13 10:29:11 2009. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default; values that are commented out # serve to show the default. # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.append(os.path.abspath('.')) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['.templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' # General information about the project. project = u'python-casacore' copyright = u'2009, Malte Marquarding, Ger van Diepen' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # from casacore import __version__ # The short X.Y version. version = __version__ # The full version, including alpha/beta/rc tags. release = __version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = ['.build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'default.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['.static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'pyrapdoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). latex_paper_size = 'a4' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'casacore.tex', 'python-casacore Documentation', 'Malte Marquarding, Ger van Diepen', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True python-casacore-2.2.1/doc/index.rst000066400000000000000000000024421320311315100172110ustar00rootroot00000000000000.. pyrap documentation master file, created by sphinx-quickstart on Thu Dec 11 14:52:50 2008. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to python-casacore's documentation! =========================================== `python-casacore `_ is a python binding to the `casacore `_ library. It consists of the following modules: :mod:`casacore.util` Common utility functions :mod:`casacore.tables` Relational data base like table system supporting multi-dimensional arrays. :mod:`casacore.images` and :mod:`casacore.images.coordinates` Access, arithmetic, and analysis on multi-dimensional images. :mod:`casacore.functionals` Functions with one or more dimensions :mod:`casacore.fitting` Fitting data to functionals. :mod:`casacore.quanta` Handling of values and units. :mod:`casacore.measures` Handling of astronomical coordinates Contents: .. toctree:: :maxdepth: 3 casacore_util.rst casacore_tables.rst casacore_images.rst casacore_functionals.rst casacore_fitting.rst casacore_quanta.rst casacore_measures.rst Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-casacore-2.2.1/pyrap/000077500000000000000000000000001320311315100157345ustar00rootroot00000000000000python-casacore-2.2.1/pyrap/__init__.py000066400000000000000000000000461320311315100200450ustar00rootroot00000000000000""" backwards compatibility module """python-casacore-2.2.1/pyrap/fitting.py000066400000000000000000000000361320311315100177510ustar00rootroot00000000000000from casacore.fitting import *python-casacore-2.2.1/pyrap/functionals.py000066400000000000000000000000421320311315100206270ustar00rootroot00000000000000from casacore.functionals import *python-casacore-2.2.1/pyrap/images.py000066400000000000000000000000001320311315100175410ustar00rootroot00000000000000python-casacore-2.2.1/pyrap/images/000077500000000000000000000000001320311315100172015ustar00rootroot00000000000000python-casacore-2.2.1/pyrap/images/__init__.py000066400000000000000000000000351320311315100213100ustar00rootroot00000000000000from casacore.images import *python-casacore-2.2.1/pyrap/images/coordinates.py000066400000000000000000000000511320311315100220610ustar00rootroot00000000000000from casacore.images.coordinates import *python-casacore-2.2.1/pyrap/images/image.py000066400000000000000000000000431320311315100206320ustar00rootroot00000000000000from casacore.images.image import *python-casacore-2.2.1/pyrap/measures.py000066400000000000000000000000371320311315100201320ustar00rootroot00000000000000from casacore.measures import *python-casacore-2.2.1/pyrap/quanta.py000066400000000000000000000000351320311315100175750ustar00rootroot00000000000000from casacore.quanta import *python-casacore-2.2.1/pyrap/tables.py000066400000000000000000000000351320311315100175560ustar00rootroot00000000000000from casacore.tables import *python-casacore-2.2.1/pyrap/util.py000066400000000000000000000000331320311315100172570ustar00rootroot00000000000000from casacore.util import *python-casacore-2.2.1/setup.py000077500000000000000000000123261320311315100163220ustar00rootroot00000000000000#!/usr/bin/env python """ Setup script for the CASACORE python wrapper. """ import os import sys import warnings from setuptools import setup, Extension, find_packages from distutils.sysconfig import get_config_vars from distutils import ccompiler from distutils.version import LooseVersion import argparse import ctypes from casacore import __version__, __mincasacoreversion__ def find_library_file(libname): ''' Try to get the directory of the specified library. It adds to the search path the library paths given to distutil's build_ext. ''' # Use a dummy argument parser to get user specified library dirs parser = argparse.ArgumentParser(add_help=False) parser.add_argument("--library-dirs", "-L", default='') args, unknown = parser.parse_known_args() user_libdirs = args.library_dirs.split(':') # Append default search path (not a complete list) libdirs = user_libdirs+[os.path.join(sys.prefix,'lib'),'/usr/local/lib', '/usr/lib','/usr/lib/x86_64-linux-gnu'] compiler = ccompiler.new_compiler() return compiler.find_library_file(libdirs, libname) # remove the strict-prototypes warning during compilation (opt,) = get_config_vars('OPT') os.environ['OPT'] = " ".join( flag for flag in opt.split() if flag != '-Wstrict-prototypes' ) def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() if sys.version_info[0] == 2: casa_python = 'casa_python' else: casa_python = 'casa_python3' def find_boost(): """Find the name of the boost-python library. Returns None if none is found.""" boostlibnames = ['boost_python-py%s%s' % (sys.version_info[0], sys.version_info[1])] boostlibnames += ['boost_python'] if sys.version_info[0] == 2: boostlibnames += ["boost_python-mt"] else: boostlibnames += ["boost_python3-mt"] for libboostname in boostlibnames: if find_library_file(libboostname): return libboostname return None boost_python = find_boost() if not boost_python: warnings.warn("Could not find a boost library") extension_metas = ( # name, sources, depends, libraries ( "casacore.fitting._fitting", ["src/fit.cc", "src/fitting.cc"], ["src/fitting.h"], ['casa_scimath', 'casa_scimath_f', boost_python, casa_python], ), ( "casacore.functionals._functionals", ["src/functional.cc", "src/functionals.cc"], ["src/functionals.h"], ['casa_scimath', 'casa_scimath_f', boost_python, casa_python], ), ( "casacore.images._images", ["src/images.cc", "src/pyimages.cc"], ["src/pyimages.h"], ['casa_images', 'casa_coordinates', 'casa_fits', 'casa_lattices', 'casa_measures', 'casa_scimath', 'casa_scimath_f', 'casa_tables', 'casa_mirlib', boost_python, casa_python] ), ( "casacore.measures._measures", ["src/pymeas.cc", "src/pymeasures.cc"], ["src/pymeasures.h"], ['casa_measures', 'casa_scimath', 'casa_scimath_f', 'casa_tables', boost_python, casa_python] ), ( "casacore.quanta._quanta", ["src/quanta.cc", "src/quantamath.cc", "src/quantity.cc", "src/quantvec.cc"], ["src/quanta.h"], ["casa_casa", boost_python, casa_python], ), ( "casacore.tables._tables", ["src/pytable.cc", "src/pytableindex.cc", "src/pytableiter.cc", "src/pytablerow.cc", "src/tables.cc", "src/pyms.cc"], ["src/tables.h"], ['casa_tables', 'casa_ms', boost_python, casa_python], ) ) # Find casacore libpath libcasacasa=find_library_file('casa_casa') if not libcasacasa: warnings.warn("Could not find libcasa_casa.so") # Get version number from casacore try: libcasa = ctypes.cdll.LoadLibrary(libcasacasa) getCasacoreVersion = libcasa.getVersion getCasacoreVersion.restype = ctypes.c_char_p casacoreversion = getCasacoreVersion() except: # getVersion was fixed in casacore 2.3.0 warnings.warn("Your casacore version is older than 2.3.0 and incompatible with this version of python-casacore") else: if LooseVersion(casacoreversion.decode()) < LooseVersion(__mincasacoreversion__): warnings.warn("Your casacore version is too old. Minimum is " + __mincasacoreversion__) extensions = [] for meta in extension_metas: name, sources, depends, libraries = meta # Add dependency on casacore libraries to trigger rebuild at casacore update for library in libraries: if library and 'casa' in library: found_lib=find_library_file(library) if found_lib: depends=depends+[found_lib] extensions.append(Extension(name=name, sources=sources, depends=depends, libraries=libraries)) setup(name='python-casacore', version=__version__, description='A wrapper around CASACORE, the radio astronomy library', install_requires=['numpy', 'argparse'], author='Gijs Molenaar', author_email='gijs@pythonic.nl', url='https://github.com/casacore/python-casacore', keywords=['pyrap', 'casacore', 'utilities', 'astronomy'], long_description=read('README.rst'), packages=find_packages(), ext_modules=extensions, license='GPL') python-casacore-2.2.1/src/000077500000000000000000000000001320311315100153705ustar00rootroot00000000000000python-casacore-2.2.1/src/fit.cc000077500000000000000000000057111320311315100164700ustar00rootroot00000000000000//# fit.cc: python module for fitting proxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pyfit.cc,v 1.2 2007/03/08 22:51:10 mmarquar Exp $ #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void fit() { class_ ("fitting") .def (init<>()) .def ("getid", &FittingProxy::getid) .def ("getstate", &FittingProxy::getstate) .def ("init", &FittingProxy::init) .def ("done", &FittingProxy::done) .def ("reset", &FittingProxy::reset) .def ("set", &FittingProxy::set) .def ("functional", &FittingProxy::functional, (boost::python::arg("id"), boost::python::arg("fnct"), boost::python::arg("x"), boost::python::arg("y"), boost::python::arg("wt"), boost::python::arg("mxit"), boost::python::arg("constraint"))) .def ("linear", &FittingProxy::linear, (boost::python::arg("id"), boost::python::arg("fnct"), boost::python::arg("x"), boost::python::arg("y"), boost::python::arg("wt"), boost::python::arg("constraint"))) .def ("cxfunctional", &FittingProxy::cxfunctional, (boost::python::arg("id"), boost::python::arg("fnct"), boost::python::arg("x"), boost::python::arg("y"), boost::python::arg("wt"), boost::python::arg("mxit"), boost::python::arg("constraint"))) .def ("cxlinear", &FittingProxy::cxlinear, (boost::python::arg("id"), boost::python::arg("fnct"), boost::python::arg("x"), boost::python::arg("y"), boost::python::arg("wt"), boost::python::arg("constraint"))) ; } }} python-casacore-2.2.1/src/fitting.cc000077500000000000000000000033071320311315100173510ustar00rootroot00000000000000//# fitting.cc: python module for casacore fitting //# Copyright (C) 2006,2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: fitting.cc,v 1.1 2006/10/20 06:30:03 mmarquar Exp $ #include #include "fitting.h" #include #include #include #include BOOST_PYTHON_MODULE(_fitting) { casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_record(); casa::python::fit(); } python-casacore-2.2.1/src/fitting.h000077500000000000000000000026641320311315100172200ustar00rootroot00000000000000//# fitting.cc: python module for casacore fitting //# Copyright (C) 2006,2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: fitting.h,v 1.1 2006/10/20 06:30:03 mmarquar Exp $ #ifndef PYRAP_FITTING_H #define PYRAP_FITTING_H #include namespace casacore { namespace python { void fit(); } // python } //casa #endif python-casacore-2.2.1/src/functional.cc000077500000000000000000000050701320311315100200460ustar00rootroot00000000000000//# functionals.cc: python module for casacore functionals. //# Copyright (C) 2006,2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pyfunctional.cc,v 1.1 2006/09/29 06:42:55 mmarquar Exp $ #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void functional() { class_ ("_functional") .def ( init< const Record&, int>()) .def ("_f", &FunctionalProxy::f) .def ("_fc", &FunctionalProxy::fc) .def ("_fdf", &FunctionalProxy::fdf) .def ("_fdfc", &FunctionalProxy::fdfc) .def ("_add", &FunctionalProxy::add) .def ("_addc", &FunctionalProxy::addc) .def ("todict", &FunctionalProxy::asrecord) .def ("npar", &FunctionalProxy::npar) .def ("ndim", &FunctionalProxy::ndim) .def ("_setparameters", &FunctionalProxy::setparameters) .def ("_setparametersc", &FunctionalProxy::setparametersc) .def ("_setpar", &FunctionalProxy::setpar) .def ("_setparc", &FunctionalProxy::setparc) .def ("_parameters", &FunctionalProxy::parameters) .def ("_parametersc", &FunctionalProxy::parametersc) .def ("_setmasks", &FunctionalProxy::setmasks) .def ("_masks", &FunctionalProxy::masks) .def ("_setmask", &FunctionalProxy::setmask) ; } } } python-casacore-2.2.1/src/functionals.cc000077500000000000000000000033441320311315100202330ustar00rootroot00000000000000//# functionals.cc: python module for casacore functionals //# Copyright (C) 2006,2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pyfunctionals.cc,v 1.2 2006/10/17 03:37:27 gvandiep Exp $ #include "functionals.h" #include #include #include #include #include BOOST_PYTHON_MODULE(_functionals) { casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_record(); casa::python::functional(); } python-casacore-2.2.1/src/functionals.h000077500000000000000000000027201320311315100200720ustar00rootroot00000000000000//# functional.cc: python module for casacore functionals //# Copyright (C) 2006,2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pyfunctionals.h,v 1.1 2006/09/29 06:42:55 mmarquar Exp $ #ifndef PYRAP_FUNCTIONALS_H #define PYRAP_FUNCTIONALS_H #include namespace casacore { namespace python { void functional(); } // python } //casa #endif python-casacore-2.2.1/src/images.cc000077500000000000000000000042561320311315100171560ustar00rootroot00000000000000//# pymeas.cc: python module for ImageProxy object. //# Copyright (C) 2008 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pyimages.cc,v 1.1 2006/09/28 05:55:00 mmarquar Exp $ #include "pyimages.h" #include #include #include #include #include #include #include #include BOOST_PYTHON_MODULE(_images) { // Register the required pyrap converters. casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_valueholder(); casa::python::register_convert_casa_record(); casa::python::register_convert_std_vector(); // Register the FITS and Miriad image types. casa::FITSImage::registerOpenFunction(); casa::MIRIADImage::registerOpenFunction(); // Make python interface to images. casa::python::pyimages(); } python-casacore-2.2.1/src/pyimages.cc000077500000000000000000000151231320311315100175220ustar00rootroot00000000000000//# pyimages.cc: python module for aips++ images system //# Copyright (C) 2008 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pyimages() { // Note that all constructors must have a different number of arguments. class_ ("Image") // 1 arg: copy constructor .def (init()) // 2 arg: concat from image names .def (init, Int>()) // 3 arg: open image or image expression .def (init >()) // 4 arg: concat from images objects .def (init, Int, Int, Int>()) // 8 arg: create image from array .def (init()) // 9 arg: create image from shape .def (init()) // Member functions. // Functions starting with un underscore are wrapped in image.py. .def ("_ispersistent", &ImageProxy::isPersistent) .def ("_name", &ImageProxy::name, (boost::python::arg("strippath"))) .def ("_shape", &ImageProxy::shape) .def ("_ndim", &ImageProxy::ndim) .def ("_size", &ImageProxy::size) .def ("_datatype", &ImageProxy::dataType) .def ("_imagetype", &ImageProxy::imageType) .def ("_getdata", &ImageProxy::getData) .def ("_getmask", &ImageProxy::getMask) .def ("_putdata", &ImageProxy::putData) .def ("_putmask", &ImageProxy::putMask) .def ("_haslock", &ImageProxy::hasLock, (boost::python::arg("write"))) .def ("_lock", &ImageProxy::lock, (boost::python::arg("write"), boost::python::arg("nattempts"))) .def ("_unlock", &ImageProxy::unlock) .def ("_attrgroupnames", &ImageProxy::attrGroupNames) .def ("_attrcreategroup", &ImageProxy::createAttrGroup, (boost::python::arg("groupname"))) .def ("_attrnames", &ImageProxy::attrNames, (boost::python::arg("groupname"))) .def ("_attrnrows", &ImageProxy::attrNrows, (boost::python::arg("groupname"))) .def ("_attrget", &ImageProxy::getAttr, (boost::python::arg("groupname"), boost::python::arg("attrname"), boost::python::arg("rownr"))) .def ("_attrgetrow", &ImageProxy::getAttrRow, (boost::python::arg("groupname"), boost::python::arg("rownr"))) .def ("_attrgetunit", &ImageProxy::getAttrUnit, (boost::python::arg("groupname"), boost::python::arg("attrname"))) .def ("_attrgetmeas", &ImageProxy::getAttrMeas, (boost::python::arg("groupname"), boost::python::arg("attrname"))) .def ("_attrput", &ImageProxy::putAttr, (boost::python::arg("groupname"), boost::python::arg("attrname"), boost::python::arg("rownr"), boost::python::arg("value"), boost::python::arg("unit"), boost::python::arg("meas"))) .def ("_subimage", &ImageProxy::subImage, (boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"), boost::python::arg("dropdegenerate"))) .def ("_coordinates", &ImageProxy::coordSys) .def ("_toworld", &ImageProxy::toWorld, (boost::python::arg("pixel"), boost::python::arg("reverseAxes"))) .def ("_topixel", &ImageProxy::toPixel, (boost::python::arg("world"), boost::python::arg("reverseAxes"))) .def ("_imageinfo", &ImageProxy::imageInfo) .def ("_miscinfo", &ImageProxy::miscInfo) .def ("_unit", &ImageProxy::unit) .def ("_history", &ImageProxy::history) .def ("_tofits", &ImageProxy::toFits, (boost::python::arg("filename"), boost::python::arg("overwrite"), boost::python::arg("velocity"), boost::python::arg("optical"), boost::python::arg("bitpix"), boost::python::arg("minpix"), boost::python::arg("maxpix"))) .def ("_saveas", &ImageProxy::saveAs, (boost::python::arg("filename"), boost::python::arg("overwrite"), boost::python::arg("hdf5"), boost::python::arg("copymask"), boost::python::arg("newmaskname"), boost::python::arg("newtileshape"))) .def ("_statistics", &ImageProxy::statistics, (boost::python::arg("axes"), boost::python::arg("mask"), boost::python::arg("minMaxValues"), boost::python::arg("exclude"), boost::python::arg("robust"))) .def ("_regrid", &ImageProxy::regrid, (boost::python::arg("axes"), boost::python::arg("outname"), boost::python::arg("overwrite"), boost::python::arg("outshape"), boost::python::arg("coordsys"), boost::python::arg("interpolation"), boost::python::arg("decimate"), boost::python::arg("replicate"), boost::python::arg("refchange"), boost::python::arg("forceregrid"))) ; } }} python-casacore-2.2.1/src/pyimages.h000077500000000000000000000026111320311315100173620ustar00rootroot00000000000000//# pyimages.cc: python module for casacore images package //# Copyright (C) 2008 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: $ #ifndef PYRAP_IMAGES_H #define PYRAP_IMAGES_H #include namespace casacore { namespace python { void pyimages(); } // python } //casa #endif python-casacore-2.2.1/src/pymeas.cc000077500000000000000000000047651320311315100172140ustar00rootroot00000000000000//# pymeas.cc: python module for MeasuresProxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pymeas.cc,v 1.1 2006/09/28 05:55:00 mmarquar Exp $ #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pymeas() { class_ ("measures") .def (init<>()) .def ("measure", &MeasuresProxy::measure) .def ("dirshow", &MeasuresProxy::dirshow) .def ("doframe", &MeasuresProxy::doframe) .def ("linelist", &MeasuresProxy::linelist) .def ("obslist", &MeasuresProxy::obslist) .def ("source", &MeasuresProxy::source) .def ("line", &MeasuresProxy::line) .def ("observatory", &MeasuresProxy::observatory) .def ("srclist", &MeasuresProxy::srclist) .def ("doptofreq", &MeasuresProxy::doptofreq) .def ("doptorv", &MeasuresProxy::doptorv) .def ("todop", &MeasuresProxy::todop) .def ("torest", &MeasuresProxy::torest) .def ("separation", &MeasuresProxy::separation) .def ("posangle", &MeasuresProxy::posangle) .def ("uvw", &MeasuresProxy::uvw) .def ("expand", &MeasuresProxy::expand) .def ("alltyp", &MeasuresProxy::alltyp) ; } }} python-casacore-2.2.1/src/pymeasures.cc000077500000000000000000000033331320311315100201010ustar00rootroot00000000000000//# pyemasures.cc: python module for aips++ measures system //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pymeasures.cc,v 1.2 2006/10/17 03:37:27 gvandiep Exp $ #include #include #include //#include #include #include "pymeasures.h" BOOST_PYTHON_MODULE(_measures) { casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_record(); casa::python::pymeas(); } python-casacore-2.2.1/src/pymeasures.h000077500000000000000000000027101320311315100177410ustar00rootroot00000000000000//# pymeasures.cc: python module for AIPS++ measures system //# Copyright (C) 2006, 2007 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pymeasures.h,v 1.1 2006/09/28 05:55:00 mmarquar Exp $ #ifndef PYRAP_MEASURES_H #define PYRAP_PYMEASURES_H #include namespace casacore { namespace python { void pymeas(); } // python } //casa #endif python-casacore-2.2.1/src/pyms.cc000066400000000000000000000217311320311315100166730ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::python; namespace casacore { // Get the required table descriptions for the given table. // If "" or "MAIN", the table descriptions for a Measurement Set // will be supplied, otherwise table should be some valid // MeasurementSet subtable TableDesc required_table_desc(const String & table) { String table_ = table; // Upper case things to be sure table_.upcase(); if(table_.empty() || table_ == "MAIN") { TableDesc tabdesc = MeasurementSet::requiredTableDesc(); // Remove the CATEGORY keyword from the FLAG_CATEGORY column // This empty Vector gets converted to a python dictionary as // 'FLAG_CATEGORY' : { // ... // keywords': {'CATEGORY' : []}, // ... // } // // Due to the missing type information this gets converted // into something like Vector when passed to the C++ layer, // which results in Table Conformance errors // This is an OK solution since the C++ layer always adds this keyword // if it is missing from the MS // (see addCat()) tabdesc.rwColumnDesc("FLAG_CATEGORY") .rwKeywordSet().removeField("CATEGORY"); return tabdesc; } else if(table_ == "ANTENNA") { return MSAntenna::requiredTableDesc(); } else if(table_ == "DATA_DESCRIPTION") { return MSDataDescription::requiredTableDesc(); } else if(table_ == "DOPPLER") { return MSDoppler::requiredTableDesc(); } else if(table_ == "FEED") { return MSFeed::requiredTableDesc(); } else if(table_ == "FIELD") { return MSField::requiredTableDesc(); } else if(table_ == "FLAG_CMD") { return MSFlagCmd::requiredTableDesc(); } else if(table_ == "FREQ_OFFSET") { return MSFreqOffset::requiredTableDesc(); } else if(table_ == "HISTORY") { return MSHistory::requiredTableDesc(); } else if(table_ == "OBSERVATION") { return MSObservation::requiredTableDesc(); } else if(table_ == "POINTING") { return MSPointing::requiredTableDesc(); } else if(table_ == "POLARIZATION") { return MSPolarization::requiredTableDesc(); } else if(table_ == "PROCESSOR") { return MSProcessor::requiredTableDesc(); } else if(table_ == "SOURCE") { return MSSource::requiredTableDesc(); } else if(table_ == "SPECTRAL_WINDOW") { return MSSpectralWindow::requiredTableDesc(); } else if(table_ == "STATE") { return MSState::requiredTableDesc(); } else if(table_ == "SYSCAL") { return MSSysCal::requiredTableDesc(); } else if(table_ == "WEATHER") { return MSWeather::requiredTableDesc(); } throw TableError("Unknown table type: " + table_); } // Get the required table descriptions for the given table. // If "" or "MAIN", the table descriptions for a Measurement Set // will be supplied, otherwise table should be some valid // MeasurementSet subtable Record required_ms_desc(const String & table) { return TableProxy::getTableDesc(required_table_desc(table), true); } // Merge required and user supplied Table Descriptions TableDesc merge_required_and_user_table_descs(const TableDesc & required_td, const TableDesc & user_td) { TableDesc result = required_td; // Overwrite required columns with user columns for(uInt i=0; i < user_td.ncolumn(); ++i) { const String & name = user_td[i].name(); // Remove if present in required if(result.isColumn(name)) { result.removeColumn(name); } // Add the column result.addColumn(user_td[i]); } // Overwrite required hypercolumns with user hypercolumns // In practice this shouldn't be necessary as requiredTableDesc // doesn't define hypercolumns by default... Vector user_hc = user_td.hypercolumnNames(); for(uInt i=0; i < user_hc.size(); ++i) { // Remove if hypercolumn is present if(result.isHypercolumn(user_hc[i])) { result.removeHypercolumnDesc(user_hc[i]); } Vector dataColumnNames; Vector coordColumnNames; Vector idColumnNames; // Get the user hypercolumn uInt ndims = user_td.hypercolumnDesc(user_hc[i], dataColumnNames, coordColumnNames, idColumnNames); // Place it in result result.defineHypercolumn(user_hc[i], ndims, dataColumnNames, coordColumnNames, idColumnNames); } // Overwrite required keywords with user keywords result.rwKeywordSet().merge(user_td.keywordSet(), RecordInterface::OverwriteDuplicates); return result; } SetupNewTable default_ms_factory(const String & name, const String & subtable, const Record & table_desc, const Record & dminfo) { String msg; TableDesc user_td; // Create Table Description object from extra user table description if(!TableProxy::makeTableDesc(table_desc, user_td, msg)) { throw TableError("Error Making Table Description " + msg); } // Merge required and user table descriptions TableDesc final_desc = merge_required_and_user_table_descs( required_table_desc(subtable), user_td); // Return SetupNewTable object SetupNewTable setup = SetupNewTable(name, final_desc, Table::New); // Apply any data manager info setup.bindCreate(dminfo); return setup; } TableProxy default_ms_subtable(const String & subtable, String name, const Record & table_desc, const Record & dminfo) { String table_ = subtable; table_.upcase(); if(name.empty() || name == "MAIN") { name = "MeasurementSet.ms"; } SetupNewTable setup_new_table = default_ms_factory(name, subtable, table_desc, dminfo); if(table_.empty() || subtable == "MAIN") { return TableProxy(MeasurementSet(setup_new_table)); } else if(table_ == "ANTENNA") { return TableProxy(MSAntenna(setup_new_table)); } else if(table_ == "DATA_DESCRIPTION") { return TableProxy(MSDataDescription(setup_new_table)); } else if(table_ == "DOPPLER") { return TableProxy(MSDoppler(setup_new_table)); } else if(table_ == "FEED") { return TableProxy(MSFeed(setup_new_table)); } else if(table_ == "FIELD") { return TableProxy(MSField(setup_new_table)); } else if(table_ == "FLAG_CMD") { return TableProxy(MSFlagCmd(setup_new_table)); } else if(table_ == "FREQ_OFFSET") { return TableProxy(MSFreqOffset(setup_new_table)); } else if(table_ == "HISTORY") { return TableProxy(MSHistory(setup_new_table)); } else if(table_ == "OBSERVATION") { return TableProxy(MSObservation(setup_new_table)); } else if(table_ == "POINTING") { return TableProxy(MSPointing(setup_new_table)); } else if(table_ == "POLARIZATION") { return TableProxy(MSPolarization(setup_new_table)); } else if(table_ == "PROCESSOR") { return TableProxy(MSProcessor(setup_new_table)); } else if(table_ == "SOURCE") { return TableProxy(MSSource(setup_new_table)); } else if(table_ == "SPECTRAL_WINDOW") { return TableProxy(MSSpectralWindow(setup_new_table)); } else if(table_ == "STATE") { return TableProxy(MSState(setup_new_table)); } else if(table_ == "SYSCAL") { return TableProxy(MSSysCal(setup_new_table)); } else if(table_ == "WEATHER") { return TableProxy(MSWeather(setup_new_table)); } throw TableError("Unknown table type: " + table_); } TableProxy default_ms(const String & name, const Record & table_desc, const Record & dminfo) { // Create the main Measurement Set SetupNewTable setup_new_table = default_ms_factory(name, "MAIN", table_desc, dminfo); MeasurementSet ms(setup_new_table); // Create the MS default subtables ms.createDefaultSubtables(Table::New); // Create a table proxy return TableProxy(ms); } namespace python { void pyms() { def("_default_ms", &default_ms, ( boost::python::arg("name"), boost::python::arg("table_desc"))); def("_default_ms_subtable", &default_ms_subtable, ( boost::python::arg("subtable"), boost::python::arg("table_desc"))); def("_required_ms_desc", &required_ms_desc, ( boost::python::arg("table"))); } } }python-casacore-2.2.1/src/pytable.cc000077500000000000000000000267211320311315100173520ustar00rootroot00000000000000//# pytable.cc: python module for TableProxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pytable.cc,v 1.5 2006/11/08 00:12:55 gvandiep Exp $ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pytable() { // Note that all constructors must have a different number of arguments. class_ ("Table", init<>()) // 1 arg: copy constructor .def (init()) // 2 arg: table query command .def (init >()) // 3 arg: open single table .def (init()) // 4 arg: open multiple tables as concatenation .def (init, Vector, Record, int>()) // 5 arg: concatenate open tables .def (init, Vector, int, int, int>()) // 7 arg: create new table .def (init()) // 11 arg: read ascii .def (init, Vector >()) // Member functions // Functions starting with an underscore are wrapped in table.py. .def ("_flush", &TableProxy::flush, (boost::python::arg("recursive"))) .def ("_resync", &TableProxy::resync) .def ("_close", &TableProxy::close) .def ("_toascii", &TableProxy::toAscii, (boost::python::arg("asciifile"), boost::python::arg("headerfile"), boost::python::arg("columnnames"), boost::python::arg("sep"), boost::python::arg("precision"), boost::python::arg("usebrackets"))) .def ("_rename", &TableProxy::rename, (boost::python::arg("newtablename"))) .def ("_copy", &TableProxy::copy, (boost::python::arg("newtablename"), boost::python::arg("memorytable"), boost::python::arg("deep"), boost::python::arg("valuecopy"), boost::python::arg("endian"), boost::python::arg("dminfo"), boost::python::arg("copynorows"))) .def ("_copyrows", &TableProxy::copyRows, (boost::python::arg("outtable"), boost::python::arg("startrowin"), boost::python::arg("startrowout"), boost::python::arg("nrow"))) .def ("_selectrows", &TableProxy::selectRows, (boost::python::arg("rownrs"), boost::python::arg("name"))) .def ("_iswritable", &TableProxy::isWritable) .def ("_endianformat", &TableProxy::endianFormat) .def ("_lock", &TableProxy::lock, (boost::python::arg("write"), boost::python::arg("nattempts"))) .def ("_unlock", &TableProxy::unlock) .def ("_haslock", &TableProxy::hasLock, (boost::python::arg("write"))) .def ("_lockoptions", &TableProxy::lockOptions) .def ("_datachanged", &TableProxy::hasDataChanged) .def ("_ismultiused", &TableProxy::isMultiUsed, (boost::python::arg("checksubtables"))) .def ("_name", &TableProxy::tableName) .def ("_partnames", &TableProxy::getPartNames, (boost::python::arg("recursive"))) .def ("_info", &TableProxy::tableInfo) .def ("_putinfo", &TableProxy::putTableInfo, (boost::python::arg("value"))) .def ("_addreadmeline", &TableProxy::addReadmeLine, (boost::python::arg("value"))) .def ("_setmaxcachesize", &TableProxy::setMaximumCacheSize, (boost::python::arg("columnname"), boost::python::arg("nbytes"))) .def ("_rownumbers", &TableProxy::rowNumbers, (boost::python::arg("table"))) .def ("_colnames", &TableProxy::columnNames) .def ("_isscalarcol", &TableProxy::isScalarColumn, (boost::python::arg("columnname"))) .def ("_coldatatype", &TableProxy::columnDataType, (boost::python::arg("columnname"))) .def ("_colarraytype", &TableProxy::columnArrayType, (boost::python::arg("columnname"))) .def ("_ncols", &TableProxy::ncolumns) .def ("_nrows", &TableProxy::nrows) .def ("_addcols", &TableProxy::addColumns, (boost::python::arg("desc"), boost::python::arg("dminfo"), boost::python::arg("addtoparent"))) .def ("_renamecol", &TableProxy::renameColumn, (boost::python::arg("oldname"), boost::python::arg("newname"))) .def ("_removecols", &TableProxy::removeColumns, (boost::python::arg("columnnames"))) .def ("_addrows", &TableProxy::addRow, (boost::python::arg("nrows"))) .def ("_removerows", &TableProxy::removeRow, (boost::python::arg("rownrs"))) .def ("_iscelldefined", &TableProxy::cellContentsDefined, (boost::python::arg("columnname"), boost::python::arg("rownr"))) .def ("_getcell", &TableProxy::getCell, (boost::python::arg("columnname"), boost::python::arg("rownr"))) .def ("_getcellvh", &TableProxy::getCellVH, (boost::python::arg("columnname"), boost::python::arg("rownr"), boost::python::arg("value"))) .def ("_getcellslice", &TableProxy::getCellSliceIP, (boost::python::arg("columnname"), boost::python::arg("rownr"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"))) .def ("_getcellslicevh", &TableProxy::getCellSliceVHIP, (boost::python::arg("columnname"), boost::python::arg("rownr"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"), boost::python::arg("value"))) .def ("_getcol", &TableProxy::getColumn, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"))) .def ("_getcolvh", &TableProxy::getColumnVH, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"), boost::python::arg("value"))) .def ("_getvarcol", &TableProxy::getVarColumn, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"))) .def ("_getcolslice", &TableProxy::getColumnSliceIP, (boost::python::arg("columnname"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"))) .def ("_getcolslicevh", &TableProxy::getColumnSliceVHIP, (boost::python::arg("columnname"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"), boost::python::arg("value"))) .def ("_putcell", &TableProxy::putCell, (boost::python::arg("columnname"), boost::python::arg("rownr"), boost::python::arg("value"))) .def ("_putcellslice", &TableProxy::putCellSliceIP, (boost::python::arg("columnname"), boost::python::arg("rownr"), boost::python::arg("value"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"))) .def ("_putcol", &TableProxy::putColumn, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"), boost::python::arg("value"))) .def ("_putvarcol", &TableProxy::putVarColumn, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"), boost::python::arg("value"))) .def ("_putcolslice", &TableProxy::putColumnSliceIP, (boost::python::arg("columnname"), boost::python::arg("value"), boost::python::arg("blc"), boost::python::arg("trc"), boost::python::arg("inc"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"))) .def ("_getcolshapestring", &TableProxy::getColumnShapeString, (boost::python::arg("columnname"), boost::python::arg("startrow"), boost::python::arg("nrow"), boost::python::arg("rowincr"), boost::python::arg("reverseaxes"))) .def ("_getkeyword", &TableProxy::getKeyword, (boost::python::arg("columnname"), boost::python::arg("keyword"), boost::python::arg("keywordindex"))) .def ("_getkeywords", &TableProxy::getKeywordSet, (boost::python::arg("columnname"))) .def ("_putkeyword", &TableProxy::putKeyword, (boost::python::arg("columnname"), boost::python::arg("keyword"), boost::python::arg("keywordindex"), boost::python::arg("makesubrecord"), boost::python::arg("value"))) .def ("_putkeywords", &TableProxy::putKeywordSet, (boost::python::arg("columnname"), boost::python::arg("value"))) .def ("_removekeyword", &TableProxy::removeKeyword, (boost::python::arg("columnname"), boost::python::arg("keyword"), boost::python::arg("keywordindex"))) .def ("_getfieldnames", &TableProxy::getFieldNames, (boost::python::arg("columnname"), boost::python::arg("keyword"), boost::python::arg("keywordindex"))) .def ("_getdminfo", &TableProxy::getDataManagerInfo) .def ("_getdmprop", &TableProxy::getProperties, (boost::python::arg("name"), boost::python::arg("bycolumn"))) .def ("_setdmprop", &TableProxy::setProperties, (boost::python::arg("name"), boost::python::arg("properties"), boost::python::arg("bycolumn"))) .def ("_getdesc", &TableProxy::getTableDescription, (boost::python::arg("actual"), boost::python::arg("_cOrder")=true)) .def ("_getcoldesc", &TableProxy::getColumnDescription, (boost::python::arg("columnname"), boost::python::arg("actual"), boost::python::arg("_cOrder")=true)) .def ("_showstructure", &TableProxy::showStructure, (boost::python::arg("dataman"), boost::python::arg("column"), boost::python::arg("subtable"), boost::python::arg("sort"))) .def ("_getasciiformat", &TableProxy::getAsciiFormat) .def ("_getcalcresult", &TableProxy::getCalcResult) ; } }} python-casacore-2.2.1/src/pytableindex.cc000066400000000000000000000041061320311315100203700ustar00rootroot00000000000000//# pytableindex.cc: python module for TableIndexProxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pytableindex.cc,v 1.1 2006/09/19 06:44:14 gvandiep Exp $ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pytableindex() { class_ ("TableIndex", init, Bool>()) .def ("_isunique", &TableIndexProxy::isUnique) .def ("_colnames", &TableIndexProxy::columnNames) .def ("_setchanged", &TableIndexProxy::setChanged) .def ("_rownr", &TableIndexProxy::getRowNumber) .def ("_rownrs", &TableIndexProxy::getRowNumbers) .def ("_rownrsrange", &TableIndexProxy::getRowNumbersRange) ; } }} python-casacore-2.2.1/src/pytableiter.cc000066400000000000000000000035151320311315100202270ustar00rootroot00000000000000//# pytableiter.cc: python module for TableIterProxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pytableiter.cc,v 1.1 2006/09/19 06:44:14 gvandiep Exp $ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pytableiter() { class_ ("TableIter", init, String, String>()) .def ("_reset", &TableIterProxy::reset) .def ("_next", &TableIterProxy::next) ; } }} python-casacore-2.2.1/src/pytablerow.cc000066400000000000000000000040021320311315100200630ustar00rootroot00000000000000//# pytablerow.cc: python module for TableRowProxy object. //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: pytablerow.cc,v 1.2 2006/10/25 22:14:54 gvandiep Exp $ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { void pytablerow() { class_ ("TableRow", init, Bool>()) .def ("_iswritable", &TableRowProxy::isWritable) .def ("_get", &TableRowProxy::get, (boost::python::arg("rownr"))) .def ("_put", &TableRowProxy::put, (boost::python::arg("rownr"), boost::python::arg("value"), boost::python::arg("matchingfields"))) ; } }} python-casacore-2.2.1/src/quanta.cc000077500000000000000000000031661320311315100172010ustar00rootroot00000000000000//# quanta.cc: python module for casacore Quanta //# Copyright (C) 2007 //# Australia Telescope National Facility, AUSTRALIA //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning pyrap should be addressed as follows: //# Internet email: pyrap-devel@googlegroups.com //# Postal address: Australia Telescope National Facility //# PO Box 76 //# Epping NSW 1710 //# AUSTRALIA //# //# $Id:$ #include "quanta.h" #include #include #include #include BOOST_PYTHON_MODULE(_quanta) { casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_record(); casa::python::quantity(); casa::python::quantvec(); casa::python::quantamath(); } python-casacore-2.2.1/src/quanta.h000077500000000000000000000026061320311315100170410ustar00rootroot00000000000000//# quanta.h: python module for casacore Quanta //# Copyright (C) 2007 //# Australia Telescope National Facility, AUSTRALIA //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning pyrap should be addressed as follows: //# Internet email: pyrap-devel@googlegroups.com //# Postal address: Australia Telescope National Facility //# PO Box 76 //# Epping NSW 1710 //# AUSTRALIA //# //# $Id:$ #ifndef PYRAP_QUANTA_H #define PYRAP_QUANTA_H #include namespace casacore { namespace python { void quantity(); void quantvec(); void quantamath(); } // python } //casa #endif python-casacore-2.2.1/src/quantamath.cc000066400000000000000000000164321320311315100200500ustar00rootroot00000000000000//# quantamath.cc: python module for Quantum > global math. //# Copyright (C) 2007 //# Australia Telescope National Facility, AUSTRALIA //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning pyrap should be addressed as follows: //# Internet email: pyrap-devel@googlegroups.com //# Postal address: Australia Telescope National Facility //# PO Box 76 //# Epping NSW 1710 //# AUSTRALIA //# $Id:$ #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { dict constants() { dict d; const uInt N = 20; static String types[N] = { "pi", "ee", "c", "G", "h", "HI", "R", "NA", "e", "mp", "mp_me", "mu0", "epsilon0", "k", "F", "me", "re", "a0", "R0", "k2" }; static Quantity res[N] = { Quantity(C::pi,""), Quantity(C::e,""), QC::c, QC::G, QC::h, QC::HI, QC::R, QC::NA, QC::e, QC::mp, QC::mp_me, QC::mu0, QC::epsilon0, QC::k, QC::F, QC::me, QC::re, QC::a0, QC::R0, QC::k2 }; for (int i=0; i<20;++i) { d[types[i]] = res[i]; } return d; } dict unitMap(map mymap) { dict d; for (map::iterator i=mymap.begin(); i != mymap.end(); ++i) { list unitdesc; ostringstream oss; // Test for casacore > 2.0.3 #if CASACORE_MAJOR_VERSION>2 || (CASACORE_MAJOR_VERSION==2 && \ (CASACORE_MINOR_VERSION>0 || (CASACORE_MINOR_VERSION==0 \ && CASACORE_PATCH_VERSION>3))) // Use the getter introduced in casacore 2.0.4 unitdesc.append((i->second).getFullName()); #else // Do the same thing with some string parsing (yuk) oss << i->second; string namestring=oss.str(); unitdesc.append(namestring.substr(11, namestring.rfind(")")-11)); oss.str(""); #endif oss<<(i->second).getVal().getDim(); Quantity q((i->second).getVal().getFac(),oss.str()); unitdesc.append(q); d[(i->second).getName() ] = unitdesc; } return d; } dict units() { map mapSI = UnitMap::giveSI(); map mapDef = UnitMap::giveDef(); map mapCust = UnitMap::giveCust(); mapSI.insert(mapDef.begin(), mapDef.end()); mapSI.insert(mapCust.begin(), mapCust.end()); return unitMap(mapSI); } dict prefixes() { map mapPref = UnitMap::givePref(); return unitMap(mapPref); } typedef Quantum > QProxy; typedef Vector VD; void quantamath() { // misc def ("constants", &constants); def ("units", &units); def ("prefixes", &prefixes); // Quantum > functions def ("nearabs", (Bool ( * )( const QProxy&, const QProxy&, Double ) )(&nearAbs)); def ("nearabs", (Bool ( * )( const VD&, const QProxy&, Double ) )(&nearAbs)); def ("nearabs", (Bool ( * )( const QProxy&, const VD&, Double ) )(&nearAbs)); def ("near", (Bool ( * )( const QProxy&, const QProxy&, Double ) )(&near)); def ("near", (Bool ( * )( const VD&, const QProxy&, Double ) )(&near)); def ("near", (Bool ( * )( const QProxy&, const VD&, Double ) )(&near)); def ("abs", (QProxy ( * )( const QProxy&) )(&abs)); def ("pow", (QProxy ( * )( const QProxy&, Int) )(&pow)); def ("root", (QProxy ( * )( const QProxy&, Int) )(&root)); def ("sqrt", (QProxy ( * )( const QProxy&) )(&sqrt)); def ("ceil", (QProxy ( * )( const QProxy&) )(&ceil)); def ("floor", (QProxy ( * )( const QProxy&) )(&floor)); def ("sin", (QProxy ( * )( const QProxy&) )(&sin)); def ("cos", (QProxy ( * )( const QProxy&) )(&cos)); def ("tan", (QProxy ( * )( const QProxy&) )(&tan)); def ("asin", (QProxy ( * )( const QProxy&) )(&asin)); def ("acos", (QProxy ( * )( const QProxy&) )(&acos)); def ("atan", (QProxy ( * )( const QProxy&) )(&atan)); def ("atan2", (QProxy ( * )( const QProxy&, const QProxy&) )(&atan2)); def ("atan2", (QProxy ( * )( const QProxy&, const VD&) )(&atan2)); def ("atan2", (QProxy ( * )( const VD&, const QProxy&) )(&atan2)); def ("log", (QProxy ( * )( const QProxy&) )(&log)); def ("log10", (QProxy ( * )( const QProxy&) )(&log10)); def ("exp", (QProxy ( * )( const QProxy&) )(&exp)); // Quantity functions def ("nearabs", (Bool ( * )( const Quantity&, const Quantity&) )(&nearAbs)); def ("nearabs", (Bool ( * )( const Quantity&, const Quantity&, Double ) )(&nearAbs)); def ("nearabs", (Bool ( * )( const Double&, const Quantity&, Double ) )(&nearAbs)); def ("nearabs", (Bool ( * )( const Quantity&, const Double&, Double ) )(&nearAbs)); def ("near", (Bool ( * )( const Quantity&, const Quantity&) )(&near)); def ("near", (Bool ( * )( const Quantity&, const Quantity&, Double ) )(&near)); def ("near", (Bool ( * )( const Double&, const Quantity&, Double ) )(&near)); def ("near", (Bool ( * )( const Quantity&, const Double&, Double ) )(&near)); def ("abs", (Quantity ( * )( const Quantity&) )(&abs)); def ("pow", (Quantity ( * )( const Quantity&, Int) )(&pow)); def ("root", (Quantity ( * )( const Quantity&, Int) )(&root)); def ("sqrt", (Quantity ( * )( const Quantity&) )(&sqrt)); def ("ceil", (Quantity ( * )( const Quantity&) )(&ceil)); def ("floor", (Quantity ( * )( const Quantity&) )(&floor)); def ("sin", (Quantity ( * )( const Quantity&) )(&sin)); def ("cos", (Quantity ( * )( const Quantity&) )(&cos)); def ("tan", (Quantity ( * )( const Quantity&) )(&tan)); def ("asin", (Quantity ( * )( const Quantity&) )(&asin)); def ("acos", (Quantity ( * )( const Quantity&) )(&acos)); def ("atan", (Quantity ( * )( const Quantity&) )(&atan)); def ("atan2", (Quantity ( * )( const Quantity&, const Quantity&) )(&atan2)); def ("atan2", (Quantity ( * )( const Quantity&, const Double&) )(&atan2)); def ("atan2", (Quantity ( * )( const Double&, const Quantity&) )(&atan2)); def ("log", (Quantity ( * )( const Quantity&) )(&log)); def ("log10", (Quantity ( * )( const Quantity&) )(&log10)); def ("exp", (Quantity ( * )( const Quantity&) )(&exp)); } } } python-casacore-2.2.1/src/quantity.cc000066400000000000000000000161551320311315100175650ustar00rootroot00000000000000//# quantity.cc: python module for Quantum > objects. //# Copyright (C) 2007 //# Australia Telescope National Facility, AUSTRALIA //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning pyrap should be addressed as follows: //# Internet email: pyrap-devel@googlegroups.com //# Postal address: Australia Telescope National Facility //# PO Box 76 //# Epping NSW 1710 //# AUSTRALIA //# //# $Id:$ #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { Quantity fromString(const String& str) { QuantumHolder qh; String err; if ( !qh.fromString(err, str) ) { throw(AipsError(err)); } return qh.asQuantity(); } String printTime(const Quantity& q, const String& fmt, uInt prec) { MVTime mvt(q); if (fmt.empty()) { return mvt.string(prec); } return mvt.string(MVTime::giveMe(fmt), prec); } String printAngle(const Quantity& q, const String& fmt, uInt prec) { MVAngle mva(q); if (fmt.empty()) { return mva.string(prec); } return mva.string(MVAngle::giveMe(fmt), prec); } String printQuantum(const Quantity& q, const String& fmt="", uInt prec=0) { if (q.get().getFullUnit() == Unit("s")) { return printTime(q, fmt, prec); } else if (q.get().getFullUnit() == Unit("rad")) { return printAngle(q, fmt, prec); } ostringstream oss; q.print(oss); return String(oss); } // Introduce the overloaded PrintQuantum function BOOST_PYTHON_FUNCTION_OVERLOADS(printQuantumOVL, printQuantum, 1, 3) // these functions take Unit as argument, enable outside access through // strings Quantity getWithUnit(const Quantity& q, const String& u) { Unit unit(u); return q.get(unit); } Double getValueWithUnit(const Quantity& q, const String& u) { Unit unit(u); return q.getValue(unit); } Quantity fromRecord(const Record& rec) { QuantumHolder qh; String err; if ( !qh.fromRecord(err, rec) ) { throw(AipsError(err)); } return qh.asQuantity(); } bool conforms(const Quantity& left, const Quantity& right) { return (left.getFullUnit().getValue() == right.getFullUnit().getValue()); } Record toRecord(const Quantity& q) { QuantumHolder qh(q); String err; Record rec; if ( !qh.toRecord(err, rec) ) { throw(AipsError(err)); } return rec; } Quantity toTime(const Quantity& q) { if (q.check(UnitVal::TIME)) { return q; } else { Quantity q0 = MVTime(q).get(); return q0; } } Quantity toAngle(const Quantity& q) { if (q.check(UnitVal::ANGLE)) { return q; } else { Quantity q0 = MVAngle(q).get(); return q0; } } Double toUnixTime(const Quantity& q) { // MJD = JD - 2400000.5 // unix = (JD - 2440587.5) * 86400.0 const Double mjdsecToUnixsec = (2400000.5 - 2440587.5) * 86400.0; Quantity qt = toTime(q); return qt.get().getValue() + mjdsecToUnixsec; } Quantity norm(const Quantity& self, Double a) { return Quantity(MVAngle(self)(a).degree(), "deg"); } }} namespace casacore { namespace python { void quantity() { class_ ("Quantity") .def (init< >()) .def (init< const Quantity& > ()) .def (init< Double, const String& >()) .def ("__repr__", &printQuantum, (boost::python::arg("self"), boost::python::arg("fmt")="", boost::python::arg("precision")=0)) .def ("get_value", (const Double& ( Quantity::* )( ) const)(&Quantity::getValue), return_value_policy < copy_const_reference> () ) .def ("get_value", &getValueWithUnit) .def ("get_unit", &Quantity::getUnit, return_value_policy < copy_const_reference> ()) .def ("convert", (void ( Quantity::* )( const Quantity& ) )(&Quantity::convert)) .def ("convert", (void ( Quantity::* )( ) )(&Quantity::convert)) .def ("set_value", &Quantity::setValue) .def ("get", (Quantity ( Quantity::* )( ) const)(&Quantity::get)) .def ("canonical", (Quantity ( Quantity::* )( ) const)(&Quantity::get)) .def ("get", (Quantity ( Quantity::* )( const Quantity& ) const)(&Quantity::get)) .def ("get", &getWithUnit) .def ("conforms", &conforms) .def ("totime", &toTime) .def ("to_time", &toTime) .def ("toangle", &toAngle) .def ("to_angle", &toAngle) .def ("to_unix_time", &toUnixTime) .def ("to_dict", &toRecord) .def ("norm", &norm, (boost::python::arg("self"), boost::python::arg("a")=-0.5)) .def (-self) .def (self - self) .def (self -= self) .def (self -= Double()) .def (self - Double() ) .def (Double() - self) .def (+self) .def (self + self) .def (self += self) .def (self += Double()) .def (self + Double() ) .def (Double() + self) .def (self * self) .def (self *= self) .def (self *= Double()) .def (self * Double() ) .def (Double() * self) .def (self / self) .def (self /= self) .def (self /= Double()) .def (self / Double() ) .def (Double() / self) .def (self == self) .def (self == Double()) .def (Double() == self) .def (self != self) .def (self != Double()) .def (Double() != self) .def (self < self) .def (self < Double()) .def (Double() < self) .def (self <= self) .def (self <= Double()) .def (Double() <= self) .def (self > self) .def (self > Double()) .def (Double() > self) .def (self >= self) .def (self >= Double()) .def (Double() >= self) .def ("formatted", &printQuantum, printQuantumOVL((boost::python::arg("q"), boost::python::arg("fmt")="", boost::python::arg("precision")=0))) ; def ("from_string", &fromString); def ("from_dict", &fromRecord); } }} python-casacore-2.2.1/src/quantvec.cc000066400000000000000000000167631320311315100175420ustar00rootroot00000000000000//# quantity.cc: python module for Quantum > objects. //# Copyright (C) 2007 //# Australia Telescope National Facility, AUSTRALIA //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning pyrap should be addressed as follows: //# Internet email: pyrap-devel@googlegroups.com //# Postal address: Australia Telescope National Facility //# PO Box 76 //# Epping NSW 1710 //# AUSTRALIA //# //# $Id:$ #include #include #include #include #include #include #include #include #include #include #include using namespace boost::python; namespace casacore { namespace python { typedef Quantum > QProxy; typedef Vector VD; /* String qpprintQuantum(const QProxy& q) { ostringstream oss; q.print(oss); return String(oss); } */ // these functions take Unit as argument, enable outside access through // strings QProxy qpgetWithUnit(const QProxy& q, const String& u) { Unit unit(u); return q.get(unit); } VD qpgetValueWithUnit(const QProxy& q, const String& u) { Unit unit(u); return q.getValue(unit); } QProxy qpfromRecord(const Record& rec) { QuantumHolder qh; String err; if ( !qh.fromRecord(err, rec) ) { throw(AipsError(err)); } return qh.asQuantumVectorDouble(); } bool qpconforms(const QProxy& left, const QProxy& right) { return (left.getFullUnit().getValue() == right.getFullUnit().getValue()); } Record qptoRecord(const QProxy& q) { QuantumHolder qh(q); String err; Record rec; if ( !qh.toRecord(err, rec) ) { throw(AipsError(err)); } return rec; } QProxy qptoTime(const QProxy& q) { if (q.check(UnitVal::TIME)) { return q; } else { VD values = q.getValue(); Unit u = q.getUnit(); Unit outu; VD outvals(values.nelements()); for (uInt i=0; i < values.nelements(); ++i) { Quantity q0 = MVTime(Quantity(values[i], u)).get(); outu = q0.getUnit(); cout << q0 << endl; outvals[i] = q0.getValue(); } return QProxy(outvals, outu); } } QProxy qptoAngle(const QProxy& q) { if (q.check(UnitVal::ANGLE)) { return q; } else { VD values = q.getValue(); Unit u = q.getUnit(); Unit outu; VD outvals(values.nelements()); for (uInt i=0; i < values.nelements(); ++i) { Quantity q0 = MVAngle(Quantity(values[i], u)).get(); outu = q0.getUnit(); cout << q0 << endl; outvals[i] = q0.getValue(); } return QProxy(outvals, outu); } } QProxy norm(const QProxy& self, Double a) { VD val = self.get().getValue(); VD outval(val.nelements()); for (uInt i=0; i< val.nelements(); ++i) { outval(i) = MVAngle(val[i])(a).degree(); } return QProxy(outval, "deg"); } String printTime(const QProxy& q, const String& fmt) { ostringstream oss; VD val = q.get().getValue(); size_t n = val.nelements(); Unit u = q.get().getUnit(); oss << "["; for (size_t i=0; i < n; ++i) { MVTime mvt(Quantity(val[i], u)); if (fmt =="") { oss << mvt.string(); } else { oss << mvt.string(MVTime::giveMe(fmt)); } if ( i < n-1 ) { oss << ", "; } } oss << "]"; return String(oss); } String printAngle(const QProxy& q, const String& fmt) { ostringstream oss; VD val = q.get().getValue(); size_t n = val.nelements(); Unit u = q.get().getUnit(); oss << "["; for (size_t i=0; i < n; ++i) { MVAngle mva(Quantity(val[i], u)); if (fmt =="") { oss << mva.string(); } else { oss << mva.string(MVAngle::giveMe(fmt)); } if ( i < n-1 ) { oss << ", "; } } oss << "]"; return String(oss); } String qpprintQuantum(const QProxy& q, const String& fmt) { if (q.get().getFullUnit() == Unit("s")) { return printTime(q, fmt); } else if (q.get().getFullUnit() == Unit("rad")) { return printAngle(q, fmt); } ostringstream oss; q.print(oss); return String(oss); } }} namespace casacore { namespace python { void quantvec() { class_ ("QuantVec") .def (init< >()) .def (init< const QProxy& > ()) .def (init< const VD&, const String& >()) .def ("__repr__", &qpprintQuantum, (boost::python::arg("self"), boost::python::arg("fmt")="")) .def ("_get_value", (const VD& ( QProxy::* )( ) const)(&QProxy::getValue), return_value_policy < copy_const_reference> () ) .def ("_get_value", &qpgetValueWithUnit) .def ("get_unit", &QProxy::getUnit, return_value_policy < copy_const_reference> ()) .def ("convert", (void ( QProxy::* )( const QProxy& ) )(&QProxy::convert)) .def ("convert", (void ( QProxy::* )( ) )(&QProxy::convert)) .def ("set_value", &QProxy::setValue) .def ("get", (QProxy ( QProxy::* )( ) const)(&QProxy::get)) .def ("canonical", (QProxy ( QProxy::* )( ) const)(&QProxy::get)) .def ("get", (QProxy ( QProxy::* )( const QProxy& ) const)(&QProxy::get)) .def ("get", &qpgetWithUnit) .def ("conforms", &qpconforms) .def ("norm", &norm, (boost::python::arg("self"), boost::python::arg("a")=-0.5)) .def ("totime", &qptoTime) .def ("to_time", &qptoTime) .def ("toangle", &qptoAngle) .def ("to_angle", &qptoAngle) .def ("to_dict", &qptoRecord) .def (-self) .def (self - self) .def (self -= self) .def (self -= VD()) .def (self - VD() ) .def (VD() - self) .def (+self) .def (self + self) .def (self += self) .def (self += VD()) .def (self + VD() ) .def (VD() + self) .def (self * self) .def (self *= self) .def (self *= VD()) .def (self * VD() ) .def (VD() * self) .def (self / self) .def (self /= self) .def (self /= VD()) .def (self / VD() ) .def (VD() / self) .def (self == self) .def (self == VD()) .def (VD() == self) .def (self != self) .def (self != VD()) .def (VD() != self) .def (self < self) .def (self < VD()) .def (VD() < self) .def (self <= self) .def (self <= VD()) .def (VD() <= self) .def (self > self) .def (self > VD()) .def (VD() > self) .def (self >= self) .def (self >= VD()) .def (VD() >= self) .def ("formatted", &qpprintQuantum) ; def ("from_dict_v", &qpfromRecord); } }} python-casacore-2.2.1/src/tables.cc000077500000000000000000000040301320311315100171510ustar00rootroot00000000000000//# tables.cc: python module for AIPS++ table system //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: tables.cc,v 1.5 2006/10/17 03:37:27 gvandiep Exp $ #include "tables.h" #include #include #include #include #include #include #include BOOST_PYTHON_MODULE(_tables) { casa::python::register_convert_excp(); casa::python::register_convert_basicdata(); casa::python::register_convert_casa_valueholder(); casa::python::register_convert_casa_record(); casa::python::register_convert_std_vector(); casa::python::pytable(); casa::python::pytablerow(); casa::python::pytableiter(); casa::python::pytableindex(); casa::python::pyms(); } python-casacore-2.2.1/src/tables.h000077500000000000000000000030421320311315100170150ustar00rootroot00000000000000//# tables.cc: python module for AIPS++ table system //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: tables.h,v 1.3 2006/09/20 02:38:41 gvandiep Exp $ #ifndef APPSPYTHON_PYCASATABLE_H #define APPSPYTHON_PYCASATABLE_H #include namespace casacore { namespace python { void pytable(); void pytablerow(); void pytableiter(); void pytableindex(); void pyms(); } // python } //casa #endif python-casacore-2.2.1/tests/000077500000000000000000000000001320311315100157435ustar00rootroot00000000000000python-casacore-2.2.1/tests/disable_convert.py000066400000000000000000000124641320311315100214670ustar00rootroot00000000000000#!/usr/bin/env python from _tConvert import NUM def dotest(t): print('') print('begin dotest') print(t.testbool (True)) print(t.testbool (False)) print(t.testint (-1)) print(t.testint (10L)) print(t.testint64 (-123456789013L)) print(t.testint64 (123456789014L)) print(t.testssize (-2)) print(t.testssize (11)) print(t.testfloat (3.14)) print(t.testfloat (12)) print(t.testdouble (3.14)) print(t.testdouble (12)) print(t.teststring ("this is a string")) arr = NUM.array([2,3], NUM.int32) print(t.testint (arr[0])) print(t.testint64 (arr[0])) print(t.testfloat (arr[0])) print(t.testdouble (arr[0])) arr = NUM.array([2.2,3.2], NUM.float32) print(t.testint (arr[0])) print(t.testfloat (arr[0])) print(t.testdouble (arr[0])) arr = NUM.array([2.4,3.4], NUM.float64) print(t.testint (arr[0])) print(t.testfloat (arr[0])) print(t.testdouble (arr[0])) print(t.testipos ([2,3,4])) print(t.testipos (1)) print(t.testipos (NUM.array([2]))) print(t.testipos (NUM.array(3))) print(t.testvecint ([1,2,3,4])) print(t.testvecint ([])) print(t.testvecint ((-1,-2,-3,-4))) print(t.testvecint (-10)) print(t.testvecint (NUM.array((10,11,12)))) print(t.testvecint (NUM.array(1))) print(t.testveccomplex ([1+2j, -1-3j, -1.5+2.5j])) print(t.testvecstr (["a1","a2","b1","b2"])) print(t.testvecstr (())) print(t.testvecstr ("sc1")) print(t.teststdvecuint ([1,2,4])) print(t.teststdvecuint (())) print(t.teststdvecuint (10)) print(t.teststdvecvecuint ([[1,2,4]])) print(t.teststdvecvecuint ((()))) print(t.teststdvecvecuint (())) print(t.teststdvecvecuint ([1,2,4])) print(t.teststdvecvecuint (20)) print(t.testvh (True)) print(t.testvh (2)) print(t.testvh (1234567890123L)) print(t.testvh (1.3)) print(t.testvh (10-11j)) print(t.testvh ("str")) print(t.testvh ([True]) + 0 # add 0 to convert numpy to integer) print(t.testvh ([2,4,6,8,10])) print(t.testvh ([1.3,4,5,6])) print(t.testvh ([10-11j,1+2j])) # print(t.testvh ([])) print(t.testvh (["str1","str2"])) print(t.testvh ({"shape":[2,2],"array":["str1","str2","str3","str4"]})) a = t.testvh ({"shape":[2,2],"array":["str1","str2","str3","str4"]}) print(a) print(t.testvh (a)) a = t.testvh ([10-11j,1+2j]) print(a.shape) print(t.testvh (a)) b = NUM.int32([[2,3],[4,5]]) print(b) print(t.testvh (b)) b = NUM.int32([1,2,3,4,5,6,7,8,9,10]) print(b[2:9:2]) print(t.testvh (b[2:9:2])) b = NUM.array([1,2,3,4,5,6,7,8,9,10.]) print(b[2:9:2]) print(t.testvh (b[2:9:2])) a = b[2:9:2] print(t.testvh (a)) print(t.testvh(NUM.array([20.+10j]))) print(t.testvh(NUM.array(21.))) print('>>>') res = t.testvh (NUM.array([])) print('<<<') print(res.shape) print('>>>') res = t.testvh (NUM.array([[]])) print('<<<') print(res.shape) # On 64-bit machines the output also contains 'dtype=int32' # So leave it out. a = t.testrecord({"int":1, "int64":123456789012L, "str":"bc", 'vecint':[1,2,3]}) print('>>>') print(a) print('<<<') print('end dotest') print('') def testarrvh(arr): print(' testarrvh') print(t.testvh(arr)) print(t.testvh(arr[0])) print(t.testvh([arr[0]])) print(t.testvh([arr[0], arr[1]])) def testarrb(arr): testarrvh(arr) print(t.testbool(arr[0])) def testarri(arr): testarrvh(arr) print(t.testint(arr[0])) print(t.testint64(arr[0])) print(t.testssize(arr[0])) print(t.testfloat(arr[0])) print(t.testcomplex(arr[0])) def testarrf(arr): testarrvh(arr) print(t.testfloat(arr[0])) print(t.testcomplex(arr[0])) def testarrc(arr): testarrvh(arr) print(t.testcomplex(arr[0])) def testnps(): testarrb(NUM.array([True,False])) testarri(NUM.int8([-6,-7])) testarri(NUM.uint8([5,6])) testarri(NUM.int16([-16,-17])) testarri(NUM.uint16([15,16])) testarri(NUM.int32([-26,-27])) testarri(NUM.uint32([25,26])) testarri(NUM.int64([-36,-37])) testarri(NUM.uint64([35,36])) testarrf(NUM.float32([-46,-47])) testarrf(NUM.float64([45,46])) testarrc(NUM.complex64([-56-66j,-57-67j])) testarrc(NUM.complex128([-76-86j,-77-87j])) def testnp(): # Test byte and sbyte. b = NUM.int8([-1,-2]) print(t.testvh(b)) b = NUM.uint8([211,212]) print(t.testvh(b)) print('>>>') res = t.testvh(NUM.array([])) print('<<<') print(res.shape) print(t.testvh(NUM.array([["abcd","c"],["12","x12"]]))) testnps() def testna(): # Test byte and sbyte. b = NUM.array([-1,-2], NUM.Int8) print(t.testvh(b)) # UInt8 is Bool, therefore use Int16. b = NUM.array([211,212], NUM.Int16) print(t.testvh(b)) print('>>>') res = t.testvh(NUM.array()) print('<<<') print(res.shape) print(t.testvh({'shape':[2,2], 'array':['abcd','c','12','x12']})) t = tConvert() print("Doing numpy/array test ...") if t.canusenumpy(): import numpy as NUM testnp() else: import numarray as NUM testna() dotest(t) print("") print("Doing numarray/py test ...") if t.canusenumarray(): import numarray as NUM testna() import numpy as NUM testnps() else: import numpy as NUM testnp() dotest(t) python-casacore-2.2.1/tests/requirements.txt000066400000000000000000000000611320311315100212240ustar00rootroot00000000000000nose unittest2 coverage coveralls travis-sphinx python-casacore-2.2.1/tests/tConvert.cc000066400000000000000000000123771320311315100200700ustar00rootroot00000000000000//# tConvert.cc: Test program for libpyrap's C++/Python converters //# Copyright (C) 2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: tConvert.cc,v 1.4 2006/11/06 00:14:44 gvandiep Exp $ #include #include #include #include #include #include #include using namespace boost::python; namespace casa { namespace pyrap { template std::ostream& operator<< (std::ostream& os, const std::vector& vec) { os << '['; for (uInt i=0; i 0) os << ", "; os << "vecuInt " << vec[i]; } os << ']'; return os; } struct TConvert { TConvert() {} Bool testbool (Bool in) {cout << "bool " << in << endl; return in;} Int testint (Int in) {cout << "Int " << in << endl; return in;} Int64 testint64 (Int64 in) {cout << "Int64 " << in << endl; return in;} Int testssize (::ssize_t in) {cout << "ssize " << in << endl; return in;} Float testfloat (Float in) {cout << "Float " << in << endl; return in;} Double testdouble (Double in) {cout << "Double " << in << endl; return in;} Complex testcomplex (const Complex& in) {cout << "Complex " << in << endl; return in;} DComplex testdcomplex (const DComplex& in) {cout << "DComplex " << in << endl; return in;} String teststring (const String& in) {cout << "String " << in << endl; String out=in; return out;} Record testrecord (const Record& in) {cout << "Record "; in.print(cout); cout << endl; return in;} ValueHolder testvh (const ValueHolder& in) {cout << "VH " << in.dataType() << endl; return in;} Vector testvecint (const Vector& in) {cout << "VecInt " << in << endl; return in;} Vector testveccomplex (const Vector& in) {cout << "VecComplex " << in << endl; return in;} Vector testvecstr (const Vector& in) {cout << "VecStr " << in << endl; return in;} std::vector teststdvecuint (const std::vector& in) {cout << "vecuInt " << in << endl; return in;} std::vector > teststdvecvecuint (const std::vector >& in) {cout << "vecvecuInt " << in << endl; return in;} IPosition testipos (const IPosition& in) {cout << "IPos " << in << endl; return in;} Bool canusenumpy() {return PycCanUseNumpy();} Bool canusenumarray() {return PycCanUseNumarray();} }; void testConvert() { class_ ("tConvert", init<>()) .def ("testbool", &TConvert::testbool) .def ("testint", &TConvert::testint) .def ("testint64", &TConvert::testint64) .def ("testssize", &TConvert::testssize) .def ("testfloat", &TConvert::testfloat) .def ("testdouble", &TConvert::testdouble) .def ("testcomplex", &TConvert::testcomplex) .def ("testdcomplex", &TConvert::testdcomplex) .def ("teststring", &TConvert::teststring) .def ("testrecord", &TConvert::testrecord) .def ("testvh", &TConvert::testvh) .def ("testvecint", &TConvert::testvecint) .def ("testveccomplex", &TConvert::testveccomplex) .def ("testvecstr", &TConvert::testvecstr) .def ("teststdvecuint", &TConvert::teststdvecuint) .def ("teststdvecvecuint", &TConvert::teststdvecvecuint) .def ("testipos", &TConvert::testipos) .def ("canusenumpy", &TConvert::canusenumpy) .def ("canusenumarray", &TConvert::canusenumarray) ; } }} BOOST_PYTHON_MODULE(_tConvert) { // Register the required converters. casa::pyrap::register_convert_excp(); casa::pyrap::register_convert_basicdata(); casa::pyrap::register_convert_casa_valueholder(); casa::pyrap::register_convert_casa_record(); casa::pyrap::register_convert_std_vector(); casa::pyrap::register_convert_std_vector >(); // Execute the test. casa::pyrap::testConvert(); } python-casacore-2.2.1/tests/tConvert.py.out000066400000000000000000000212311320311315100207260ustar00rootroot00000000000000Doing numpy/array test ... VH Array [-1 -2] VH Array [211 212] >>> VH Array <<< (0,) VH Array {'shape': [2, 2], 'array': ['abcd', 'c', '12', 'x12']} testarrvh VH Array [ True False] VH Bool True VH Array [ True] VH Array [ True False] bool 1 True testarrvh VH Array [-6 -7] VH Int -6 VH Array [-6] VH Array [-6 -7] Int -6 -6 Int64 -6 -6 ssize -6 -6 Float -6 -6.0 Complex (-6,0) (-6+0j) testarrvh VH Array [5 6] VH Int 5 VH Array [5] VH Array [5 6] Int 5 5 Int64 5 5 ssize 5 5 Float 5 5.0 Complex (5,0) (5+0j) testarrvh VH Array [-16 -17] VH Int -16 VH Array [-16] VH Array [-16 -17] Int -16 -16 Int64 -16 -16 ssize -16 -16 Float -16 -16.0 Complex (-16,0) (-16+0j) testarrvh VH Array [15 16] VH Int 15 VH Array [15] VH Array [15 16] Int 15 15 Int64 15 15 ssize 15 15 Float 15 15.0 Complex (15,0) (15+0j) testarrvh VH Array [-26 -27] VH Int -26 VH Array [-26] VH Array [-26 -27] Int -26 -26 Int64 -26 -26 ssize -26 -26 Float -26 -26.0 Complex (-26,0) (-26+0j) testarrvh VH Array [25 26] VH Int 25 VH Array [25] VH Array [25 26] Int 25 25 Int64 25 25 ssize 25 25 Float 25 25.0 Complex (25,0) (25+0j) testarrvh VH Array [-36 -37] VH Int64 -36 VH Array [-36] VH Array [-36 -37] Int -36 -36 Int64 -36 -36 ssize -36 -36 Float -36 -36.0 Complex (-36,0) (-36+0j) testarrvh VH Array [35 36] VH Int64 35 VH Array [35] VH Array [35 36] Int 35 35 Int64 35 35 ssize 35 35 Float 35 35.0 Complex (35,0) (35+0j) testarrvh VH Array [-46. -47.] VH float -46.0 VH Array [-46.] VH Array [-46. -47.] Float -46 -46.0 Complex (-46,0) (-46+0j) testarrvh VH Array [ 45. 46.] VH double 45.0 VH Array [ 45.] VH Array [ 45. 46.] Float 45 45.0 Complex (45,0) (45+0j) testarrvh VH Array [-56.-66.j -57.-67.j] VH Complex (-56-66j) VH Array [-56.-66.j] VH Array [-56.-66.j -57.-67.j] Complex (-56,-66) (-56-66j) testarrvh VH Array [-76.-86.j -77.-87.j] VH DComplex (-76-86j) VH Array [-76.-86.j] VH Array [-76.-86.j -77.-87.j] Complex (-76,-86) (-76-86j) begin dotest bool 1 True bool 0 False Int -1 -1 Int 10 10 Int64 -123456789013 -123456789013 Int64 123456789014 123456789014 ssize -2 -2 ssize 11 11 Float 3.14 3.1400001049 Float 12 12.0 Double 3.14 3.14 Double 12 12.0 String this is a string this is a string Int 2 2 Int64 2 2 Float 2 2.0 Double 2 2.0 Int 2 2 Float 2.2 2.20000004768 Double 2.2 2.20000004768 Int 2 2 Float 2.4 2.40000009537 Double 2.4 2.4 IPos [4, 3, 2] [2, 3, 4] IPos [1] [1] IPos [2] [2] IPos [3] [3] VecInt [1, 2, 3, 4] [1, 2, 3, 4] VecInt [] [] VecInt [-1, -2, -3, -4] [-1, -2, -3, -4] VecInt [-10] [-10] VecInt [10, 11, 12] [10, 11, 12] VecInt [1] [1] VecComplex [(1,2), (-1,-3), (-1.5,2.5)] [(1+2j), (-1-3j), (-1.5+2.5j)] VecStr [a1, a2, b1, b2] ['a1', 'a2', 'b1', 'b2'] VecStr [] [] VecStr [sc1] ['sc1'] vecuInt [vecuInt 1, vecuInt 2, vecuInt 4] [1, 2, 4] vecuInt [] [] vecuInt [vecuInt 10] [10] vecvecuInt [vecuInt [vecuInt 1, vecuInt 2, vecuInt 4]] [[1, 2, 4]] vecvecuInt [] [] vecvecuInt [] [] vecvecuInt [vecuInt [vecuInt 1], vecuInt [vecuInt 2], vecuInt [vecuInt 4]] [[1], [2], [4]] vecvecuInt [vecuInt [vecuInt 20]] [[20]] VH Bool True VH Int 2 VH Int64 1234567890123 VH double 1.3 VH DComplex (10-11j) VH String str VH Array [1] VH Array [ 2 4 6 8 10] VH Array [ 1.3 4. 5. 6. ] VH Array [ 10.-11.j 1. +2.j] VH Array ['str1', 'str2'] VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array (2,) VH Array [ 10.-11.j 1. +2.j] [[2 3] [4 5]] VH Array [[2 3] [4 5]] [3 5 7 9] VH Array [3 5 7 9] [ 3. 5. 7. 9.] VH Array [ 3. 5. 7. 9.] VH Array [ 3. 5. 7. 9.] VH Array [ 20.+10.j] VH Array [ 21.] >>> VH Array <<< (0,) >>> VH Array <<< (1, 0) Record int: Int 1 int64: Int64 123456789012 str: String "bc" vecint: Int array with shape [3] [1, 2, 3] >>> {'int': 1, 'int64': 123456789012L, 'str': 'bc', 'vecint': array([1, 2, 3], dtype=int32)} <<< end dotest Doing numarray/py test ... VH Array [-1 -2] VH Array [211 212] >>> VH Array <<< (0,) VH Array {'shape': [2, 2], 'array': ['abcd', 'c', '12', 'x12']} testarrvh VH Array [ True False] VH Bool True VH Array [ True] VH Array [ True False] bool 1 True testarrvh VH Array [-6 -7] VH Int -6 VH Array [-6] VH Array [-6 -7] Int -6 -6 Int64 -6 -6 ssize -6 -6 Float -6 -6.0 Complex (-6,0) (-6+0j) testarrvh VH Array [5 6] VH Int 5 VH Array [5] VH Array [5 6] Int 5 5 Int64 5 5 ssize 5 5 Float 5 5.0 Complex (5,0) (5+0j) testarrvh VH Array [-16 -17] VH Int -16 VH Array [-16] VH Array [-16 -17] Int -16 -16 Int64 -16 -16 ssize -16 -16 Float -16 -16.0 Complex (-16,0) (-16+0j) testarrvh VH Array [15 16] VH Int 15 VH Array [15] VH Array [15 16] Int 15 15 Int64 15 15 ssize 15 15 Float 15 15.0 Complex (15,0) (15+0j) testarrvh VH Array [-26 -27] VH Int -26 VH Array [-26] VH Array [-26 -27] Int -26 -26 Int64 -26 -26 ssize -26 -26 Float -26 -26.0 Complex (-26,0) (-26+0j) testarrvh VH Array [25 26] VH Int 25 VH Array [25] VH Array [25 26] Int 25 25 Int64 25 25 ssize 25 25 Float 25 25.0 Complex (25,0) (25+0j) testarrvh VH Array [-36 -37] VH Int64 -36 VH Array [-36] VH Array [-36 -37] Int -36 -36 Int64 -36 -36 ssize -36 -36 Float -36 -36.0 Complex (-36,0) (-36+0j) testarrvh VH Array [35 36] VH Int64 35 VH Array [35] VH Array [35 36] Int 35 35 Int64 35 35 ssize 35 35 Float 35 35.0 Complex (35,0) (35+0j) testarrvh VH Array [-46. -47.] VH float -46.0 VH Array [-46.] VH Array [-46. -47.] Float -46 -46.0 Complex (-46,0) (-46+0j) testarrvh VH Array [ 45. 46.] VH double 45.0 VH Array [ 45.] VH Array [ 45. 46.] Float 45 45.0 Complex (45,0) (45+0j) testarrvh VH Array [-56.-66.j -57.-67.j] VH Complex (-56-66j) VH Array [-56.-66.j] VH Array [-56.-66.j -57.-67.j] Complex (-56,-66) (-56-66j) testarrvh VH Array [-76.-86.j -77.-87.j] VH DComplex (-76-86j) VH Array [-76.-86.j] VH Array [-76.-86.j -77.-87.j] Complex (-76,-86) (-76-86j) begin dotest bool 1 True bool 0 False Int -1 -1 Int 10 10 Int64 -123456789013 -123456789013 Int64 123456789014 123456789014 ssize -2 -2 ssize 11 11 Float 3.14 3.1400001049 Float 12 12.0 Double 3.14 3.14 Double 12 12.0 String this is a string this is a string Int 2 2 Int64 2 2 Float 2 2.0 Double 2 2.0 Int 2 2 Float 2.2 2.20000004768 Double 2.2 2.20000004768 Int 2 2 Float 2.4 2.40000009537 Double 2.4 2.4 IPos [4, 3, 2] [2, 3, 4] IPos [1] [1] IPos [2] [2] IPos [3] [3] VecInt [1, 2, 3, 4] [1, 2, 3, 4] VecInt [] [] VecInt [-1, -2, -3, -4] [-1, -2, -3, -4] VecInt [-10] [-10] VecInt [10, 11, 12] [10, 11, 12] VecInt [1] [1] VecComplex [(1,2), (-1,-3), (-1.5,2.5)] [(1+2j), (-1-3j), (-1.5+2.5j)] VecStr [a1, a2, b1, b2] ['a1', 'a2', 'b1', 'b2'] VecStr [] [] VecStr [sc1] ['sc1'] vecuInt [vecuInt 1, vecuInt 2, vecuInt 4] [1, 2, 4] vecuInt [] [] vecuInt [vecuInt 10] [10] vecvecuInt [vecuInt [vecuInt 1, vecuInt 2, vecuInt 4]] [[1, 2, 4]] vecvecuInt [] [] vecvecuInt [] [] vecvecuInt [vecuInt [vecuInt 1], vecuInt [vecuInt 2], vecuInt [vecuInt 4]] [[1], [2], [4]] vecvecuInt [vecuInt [vecuInt 20]] [[20]] VH Bool True VH Int 2 VH Int64 1234567890123 VH double 1.3 VH DComplex (10-11j) VH String str VH Array [1] VH Array [ 2 4 6 8 10] VH Array [ 1.3 4. 5. 6. ] VH Array [ 10.-11.j 1. +2.j] VH Array ['str1', 'str2'] VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array {'shape': [2, 2], 'array': ['str1', 'str2', 'str3', 'str4']} VH Array (2,) VH Array [ 10.-11.j 1. +2.j] [[2 3] [4 5]] VH Array [[2 3] [4 5]] [3 5 7 9] VH Array [3 5 7 9] [ 3. 5. 7. 9.] VH Array [ 3. 5. 7. 9.] VH Array [ 3. 5. 7. 9.] VH Array [ 20.+10.j] VH Array [ 21.] >>> VH Array <<< (0,) >>> VH Array <<< (1, 0) Record int: Int 1 int64: Int64 123456789012 str: String "bc" vecint: Int array with shape [3] [1, 2, 3] >>> {'int': 1, 'int64': 123456789012L, 'str': 'bc', 'vecint': array([1, 2, 3], dtype=int32)} <<< end dotest python-casacore-2.2.1/tests/test_fitting.py000066400000000000000000000107721320311315100210270ustar00rootroot00000000000000import unittest2 as unittest from casacore import fitting, functionals import numpy as np class TestFitting(unittest.TestCase): """Test class for Fitting module.""" def setUp(self): """Set up fitserver for all the tests.""" self.fitserver = fitting.fitserver() def test_fitter(self): """Testing fitter.""" self.fitserver.fitter() def test_fitserver(self): """Testing fitserver.""" self.assertEqual(self.fitserver.getstate(), {'colfac': 1e-08, 'lmfac': 0.001, 'n': 0, 'typ': 'real'}) self.fitserver.set(n=1, colfac=1.0e-09, lmfac=1.0e-2, ftype=1) self.assertEqual(self.fitserver.getstate(), {'colfac': 1e-09, 'lmfac': 0.01, 'n': 1, 'typ': 'complex'}) def test_poly(self): """Test poly.""" x = -1 + 0.1 * np.arange(21) y = functionals.poly(2, [3.03, 2.06, 0.03])(x) self.fitserver.linear(functionals.compiled('p'), [], y) np.testing.assert_equal(self.fitserver.solution(), sum(y)/len(y)) np.testing.assert_equal(self.fitserver.sd(), self.fitserver.stddev()) np.testing.assert_allclose(self.fitserver.error(), np.array([0.27893394])) self.assertAlmostEqual(self.fitserver.chi2(), 32.6777389399999) self.assertEqual(self.fitserver.rank(), 1) np.testing.assert_allclose(self.fitserver.covariance()[0], np.array([0.04761905])) def test_functional(self): """Test functional method.""" f = functionals.compiled('p6+p0*exp(-((x-p1)/p2)^2)' + ' + p3*exp(-((x-p4)/p5)^2)', [20, 10, 4, 10, 33, 4, 10]) xg = 0.5 * np.arange(1, 101) - 0.5 yg = np.array(f(xg)) + np.random.normal(0, 0.3, 100) f.set_parameters([22, 11, 5, 10, 30, 5, 9]) self.fitserver.clearconstraints() self.fitserver.functional(f, xg, yg) print(self.fitserver.solution()) def test_complex_fitting(self): """Testing complex fitting.""" x = -1 + np.arange(0, 21)*0.1 y = functionals.poly(2, [3.03, 2.06, 0.03])(x) self.fitserver.linear(functionals.poly(1), x, y) print('linear', self.fitserver.solution()) id1 = self.fitserver.fitter() self.fitserver.set(ftype='complex', fid=id1) self.fitserver.linear(functionals.poly(1, dtype='complex'), x, y, fid=id1) np.testing.assert_allclose(self.fitserver.solution(fid=id1), np.array([3.041+0.j, 2.060+0.j])) def test_constraint(self): """Test constraint.""" from casacore import functionals as dfs yz = np.array([np.zeros(10) + 50 + np.random.normal(0, 1, 10), np.zeros(10) + 60 + np.random.normal(0, 1, 10), np.zeros(10) + 70 + np.random.normal(0, 1, 10)] ).flatten() xz = np.array([1, 0, 0]*10 + [0, 1, 0]*10 + [0, 0, 1]*10) f = dfs.compiled('p*x+p1*x1+p2*x2') self.fitserver.linear(f, xz, yz) self.fitserver.addconstraint(x=[1, 1, 1], y=180) self.fitserver.linear(f, xz, yz) self.assertEqual(sum(self.fitserver.solution()), 180.0) self.fitserver.clearconstraints() def test_fitspoly(self): """Test fitspoly.""" x = np.arange(1, 11) y = 2. + 0.5*x - 0.1*x**2 self.fitserver.fitspoly(3, x, y) np.testing.assert_allclose(self.fitserver.solution(), np.array([2.00000000e+00, 5.00000000e-01, -1.00000000e-01, -4.70734562e-14])) def test_fitavg(self): """Test fitavg.""" x = np.arange(1, 11) y = 2. + 0.5*x - 0.1*x**2 self.fitserver.fitavg(y) np.testing.assert_allclose(self.fitserver.solution(), np.array([0.9])) def test_done(self): """Test done method.""" fit = fitting.fitserver() x = np.arange(1, 11) y = 1. + 2*x - x**2 fit.fitpoly(3, x, y) np.testing.assert_allclose(fit.solution()[0], 1) fit.done() with self.assertRaises(ValueError): fit.solution() python-casacore-2.2.1/tests/test_functionals.py000066400000000000000000000245721320311315100217130ustar00rootroot00000000000000import unittest2 as unittest from casacore.functionals import * class TestFunctionals(unittest.TestCase): def test_something(self): # self.functional = functionals.functional(name='test') # functionals.chebyshev(self.functional) return def test_gaussian1d(self, dtype=None): if dtype is not None: gauss1d = gaussian1d([1, 2, 3], dtype=dtype) else: gauss1d = gaussian1d([1, 2, 3]) self.assertEqual(type(repr(gauss1d)), str) self.assertEqual(gauss1d.ndim(), 1) self.assertEqual(gauss1d.npar(), 3) self.assertEqual(gauss1d.npar(), len(gauss1d)) self.assertEqual(gauss1d.get_parameters(), [1.0, 2.0, 3.0]) gauss1d.set_parameters([4.0, 5.0, 6.0]) self.assertEqual(gauss1d.get_parameters(), [4.0, 5.0, 6.0]) gauss1d.set_parameter(0, 2) self.assertEqual(gauss1d.get_parameters()[0], 2) self.assertEqual(gauss1d.get_masks(), [True, True, True]) gauss1d.set_mask(0, False) self.assertEqual(gauss1d.get_masks()[0], False) gauss1d.set_masks([True, True, True]) self.assertEqual(gauss1d.get_masks()[0], True) numpy.testing.assert_array_equal(gauss1d(0), gauss1d.f(0)) if dtype is None: numpy.testing.assert_array_equal(gauss1d(1, derivatives=True), gauss1d.fdf(1)) def test_gaussian1d_dtype(self): self.test_gaussian1d(dtype='complex') def test_gaussian2d(self, dtype=None): if dtype is not None: gauss2d = gaussian2d(numpy.array([[1, 2, 3], [4, 5, 6]]), dtype=dtype) else: gauss2d = gaussian2d(numpy.array([[1, 2, 3], [4, 5, 6]])) self.assertEqual(type(repr(gauss2d)), str) self.assertEqual(gauss2d.ndim(), 2) self.assertEqual(gauss2d.npar(), 6) self.assertEqual(gauss2d.npar(), len(gauss2d)) self.assertEqual(gauss2d.get_parameters(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) gauss2d.set_parameters([4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) self.assertEqual(gauss2d.get_parameters(), [4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) gauss2d.set_parameter(0, 2) self.assertEqual(gauss2d.get_parameters()[0], 2) self.assertEqual(gauss2d.get_masks(), [True, True, True, True, True, True]) gauss2d.set_mask(0, False) self.assertEqual(gauss2d.get_masks()[0], False) gauss2d.set_masks([True, True, True, True, True, True]) self.assertEqual(gauss2d.get_masks()[0], True) numpy.testing.assert_array_equal(gauss2d([1, 2]), gauss2d.f([1, 2])) if dtype is None: numpy.testing.assert_array_equal(gauss2d([1, 2], derivatives=True), gauss2d.fdf([1, 2])) def test_gaussian2d_dtype(self): self.test_gaussian2d(dtype='complex') def test_poly(self, dtype=None): if dtype is not None: p = poly(3, dtype=dtype) else: p = poly(3) self.assertEqual(type(repr(p)), str) self.assertTrue(p.ndim(), 1) self.assertTrue(p.npar(), 4) self.assertEqual(p.npar(), len(p)) self.assertTrue(p.get_parameters() == [1.0, 1.0, 1.0, 1.0]) p.set_parameters([4, 3, 2, 1]) self.assertTrue(p.get_parameters() == [4.0, 3.0, 2.0, 1.0]) p.set_parameter(0, 0) self.assertEqual(p.get_parameters()[0], 0.0) self.assertEqual(p.get_masks(), [True, True, True, True]) p.set_mask(0, False) self.assertEqual(p.get_masks()[0], False) p.set_masks([True, False, True, True]) self.assertEqual(p.get_masks()[1], False) numpy.testing.assert_array_equal(p(0), p.f(0)) numpy.testing.assert_array_equal(p(1), numpy.array([6.])) if dtype is None: numpy.testing.assert_array_equal(p(0, derivatives=True), p.fdf(0)) numpy.testing.assert_array_equal( p.fdf(0), numpy.array([[0., 1., 0., 0., 0.]])) def test_poly_dtype(self): self.test_poly(dtype='complex') def test_oddpoly(self, dtype=None): if dtype is not None: op = oddpoly(3, dtype=dtype) else: op = oddpoly(3) self.assertEqual(type(repr(op)), str) self.assertTrue(op.ndim(), 1) self.assertTrue(op.npar(), 2) self.assertEqual(op.npar(), len(op)) self.assertTrue(op.get_parameters() == [1.0, 1.0]) op.set_parameters([2, 1]) self.assertTrue(op.get_parameters() == [2.0, 1.0]) op.set_parameter(0, 0) self.assertEqual(op.get_parameters()[0], 0.0) self.assertEqual(op.get_masks(), [True, True]) op.set_mask(0, False) self.assertEqual(op.get_masks()[0], False) op.set_masks([True, False]) self.assertEqual(op.get_masks()[1], False) numpy.testing.assert_array_equal(op(0), op.f(0)) numpy.testing.assert_array_equal(op(1), numpy.array([1.])) if dtype is None: numpy.testing.assert_array_equal(op(0, derivatives=True), op.fdf(0)) numpy.testing.assert_array_equal( op.fdf(1), numpy.array([[1., 1., 0.]])) def test_oddpoly_dtype(self): self.test_oddpoly(dtype='complex') def test_evenpoly(self, dtype=None): if dtype is not None: ep = evenpoly(3, dtype=dtype) else: ep = evenpoly(3) self.assertEqual(type(repr(ep)), str) self.assertTrue(ep.ndim(), 1) self.assertTrue(ep.npar(), 2) self.assertEqual(ep.npar(), len(ep)) self.assertTrue(ep.get_parameters() == [1.0, 1.0]) ep.set_parameters([2, 1]) self.assertTrue(ep.get_parameters() == [2.0, 1.0]) ep.set_parameter(0, 0) self.assertEqual(ep.get_parameters()[0], 0.0) self.assertEqual(ep.get_masks(), [True, True]) ep.set_mask(0, False) self.assertEqual(ep.get_masks()[0], False) ep.set_masks([True, False]) self.assertEqual(ep.get_masks()[1], False) numpy.testing.assert_array_equal(ep(0), ep.f(0)) numpy.testing.assert_array_equal(ep(1), numpy.array([1.])) if dtype is None: numpy.testing.assert_array_equal(ep(0, derivatives=True), ep.fdf(0)) numpy.testing.assert_array_equal( ep.fdf(1), numpy.array([[1., 1., 0.]])) def test_evenpoly_dtype(self): self.test_evenpoly(dtype='complex') def test_chebyshev(self, dtype=None): if dtype is not None: ch = chebyshev(3, dtype=dtype) else: ch = chebyshev(3) self.assertEqual(type(repr(ch)), str) self.assertTrue(ch.ndim(), 1) self.assertTrue(ch.npar(), 4) self.assertEqual(ch.npar(), len(ch)) self.assertTrue(ch.get_parameters() == [1.0, 1.0, 1.0, 1.0]) ch.set_parameters([4, 3, 2, 1]) self.assertTrue(ch.get_parameters() == [4, 3, 2, 1]) ch.set_parameter(0, 0) self.assertEqual(ch.get_parameters()[0], 0.0) self.assertEqual(ch.get_masks(), [True, True, True, True]) ch.set_mask(0, False) self.assertEqual(ch.get_masks()[0], False) ch.set_masks([True, False, True, False]) self.assertEqual(ch.get_masks()[1], False) numpy.testing.assert_array_equal(ch(0), ch.f(0)) numpy.testing.assert_array_equal(ch(1), numpy.array([6.])) if dtype is None: numpy.testing.assert_array_equal(ch(0, derivatives=True), ch.fdf(0)) numpy.testing.assert_array_equal( ch.fdf(1), numpy.array([[6., 1., 1., 1., 1.]])) # def test_chebyshev_dtype(self): # self.test_chebyshev(dtype='complex') def test_compound(self, dtype=None): if dtype is not None: p = poly(3, dtype=dtype) else: p = poly(3) self.assertEqual(type(repr(p)), str) self.assertTrue(p.ndim(), 1) self.assertTrue(p.npar(), 4) self.assertEqual(p.npar(), len(p)) self.assertTrue(p.get_parameters() == [1.0, 1.0, 1.0, 1.0]) p.set_parameters([4, 3, 2, 1]) self.assertTrue(p.get_parameters() == [4.0, 3.0, 2.0, 1.0]) p.set_parameter(0, 0) self.assertEqual(p.get_parameters()[0], 0.0) self.assertEqual(p.get_masks(), [True, True, True, True]) p.set_mask(0, False) self.assertEqual(p.get_masks()[0], False) p.set_masks([True, False, True, True]) self.assertEqual(p.get_masks()[1], False) numpy.testing.assert_array_equal(p(0), p.f(0)) numpy.testing.assert_array_equal(p(1), numpy.array([6.])) d = poly(2) gauss1d = gaussian1d([1, 0, 1]) sum = compound() sum.add(d) sum.add(gauss1d) numpy.testing.assert_allclose(sum(2), numpy.array([7.000015])) if dtype is None: numpy.testing.assert_array_equal(p(0, derivatives=True), p.fdf(0)) numpy.testing.assert_array_equal( p.fdf(0), numpy.array([[0., 1., 0., 0., 0.]])) def test_compound_dtype(self): self.test_compound(dtype='complex') def test_combi(self, dtype=None): const = poly(0) linear = poly(1) square = poly(2) c = combi() c.add(const) c.add(linear) c.add(square) print(c(0)) def test_combi_dtype(self): self.test_combi(dtype='complex') def test_compiled(self, dtype=None): a = compiled('sin(pi(0.5) ) +pi') numpy.testing.assert_allclose(a(0), numpy.array([4.14159265])) b = compiled('p*exp(-(x/p[2])^2)') self.assertEqual(b.get_parameters(), [0.0, 0.0]) b.set_parameters([10, 1]) numpy.testing.assert_allclose(b([-1, -0.5, 0, .5, 1]), numpy.array([3.67879441, 7.78800783, 10., 7.78800783, 3.67879441])) synca = compiled('((x==0) * 1)+((x!=0) * sin(x+(x==0)*1)/(x+(x==0)*1))') numpy.testing.assert_allclose(synca([-1, 0, 1]), numpy.array([0.84147098, 1., 0.84147098])) python-casacore-2.2.1/tests/test_image.py000066400000000000000000000235361320311315100204470ustar00rootroot00000000000000"""Tests casacore.images module.""" import unittest2 as unittest from casacore.images import * import numpy import tempfile import os try: import numpy.ma as nma except ImportError: import numpy.core.ma as nma class TestImage(unittest.TestCase): """Unittesting Class.""" tempdir = tempfile.gettempdir() os.chdir(tempdir) def test_image(self): """Create an image.""" im = image("testimg", shape=[4, 3]) im1 = image("", shape=[4, 3]) self.assertEqual(im.ndim(), 2) self.assertEqual(im.shape(), [4, 3]) self.assertEqual(len(im), 12) self.assertEqual(im.size(), 12) self.assertTrue(im.ispersistent()) self.assertEqual(im.datatype(), 'float') self.assertEqual(im.imagetype(), 'PagedImage') self.assertEqual(im1.name(), 'Temporary_Image') self.assertEqual(im1.imagetype(), 'TempImage') def test_write_data(self): """Write data into it.""" im = image("testimg", shape=[4, 3]) im.put(numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])) numpy.testing.assert_equal(im.getdata(), numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])) numpy.testing.assert_equal(im.getdata((0, 0), (2, 1)), numpy.array([[1, 2], [4, 5], [7, 8]])) # blc,trc,inc get adjusted numpy.testing.assert_equal(im.getdata(0, 2, 2), numpy.array([[1, 2, 3], [7, 8, 9]])) def test_image_mask(self): """Test image mask.""" im1 = image("testimg", shape=[2, 3]) im1.put(nma.masked_array(numpy.array([[1, 2, 3], [4, 5, 6]]), mask=[[False, True, False], [False, False, True]])) numpy.testing.assert_equal(im1.getmask(), numpy.array([[False, True, False], [False, False, True]])) im1.putmask(numpy.array([[True, False, True], [False, False, False]]), (0, 0), (0, 1)) numpy.testing.assert_equal(im1.getmask(), numpy.array([[True, False, True], [False, False, False]])) numpy.testing.assert_equal(im1.getdata(), numpy.array([[1, 2, 3], [4, 5, 6]])) im1.putdata(numpy.array([0, 1, 0]), (0, 0), (0, 1)) numpy.testing.assert_equal(im1.getdata(), numpy.array([[0, 1, 0], [4, 5, 6]])) def test_lock(self): """Test lock.""" im = image("testimg", shape=[2, 3]) im.saveas('timage.img1') im1 = image('timage.img1') self.assertTrue(im1.haslock()) im1.unlock() self.assertFalse(im1.haslock()) im1.lock() self.assertTrue(im1.haslock()) def test_expr(self): """Create an expression from the image.""" im = image("testimg", shape=[2, 3]) im.put(numpy.array([[1, 2, 3], [4, 5, 6]])) imex = image('$im + $im') numpy.testing.assert_equal(imex.getdata(), numpy.array([[2., 4., 6.], [8., 10., 12.]])) def test_subset(self): """Create a subset and update it.""" im = image("testimg", shape=[2, 3]) im.put(numpy.array([[1, 2, 3], [4, 5, 6]])) im1 = im.subimage(0, 1, 2) numpy.testing.assert_equal(im1.getdata(), numpy.array([1, 2, 3])) im1.putdata(im1.getdata() + 1) numpy.testing.assert_equal(im1.getdata(), numpy.array([2, 3, 4])) numpy.testing.assert_equal(im.getmask(), numpy.array([[False, False, False], [False, False, False]])) def test_concimg(self): """Create a concatenated image.""" im = image("testimg", shape=[2, 3]) im.put(numpy.array([[1, 2, 3], [4, 5, 6]])) imc1 = image((im, im)) self.assertEqual(imc1.shape(), [2, 6]) numpy.testing.assert_equal(imc1.getdata(), numpy.array([[1, 2, 3, 1, 2, 3], [4, 5, 6, 4, 5, 6]])) imc1.saveas('timage.py_tmp.img1') imc2 = image('timage.py_tmp.img1') numpy.testing.assert_equal(imc2.getdata(), numpy.array([[1, 2, 3, 1, 2, 3], [4, 5, 6, 4, 5, 6]])) def test_float(self): """Create a float image expression with a mask.""" im = image("testimg", shape=[2, 3]) im.put(numpy.array([[1, 2, 3], [4, 5, 6]])) im.saveas('timage.py_tmp.img1') imex = image('float(timage.py_tmp.img1[timage.py_tmp.img1 > 3])') numpy.testing.assert_equal(imex.getdata(), numpy.array([[1, 2, 3], [4, 5, 6]])) numpy.testing.assert_equal(imex.getmask(), numpy.array([[True, True, True], [False, False, False]])) imex.saveas('timage.py_tmp.img2', copymask=True) imex2 = image('timage.py_tmp.img2', mask='mask0') numpy.testing.assert_equal(imex2.getmask(), numpy.array([[True, True, True], [False, False, False]])) imex2.put(imex2.getdata() + 10) numpy.testing.assert_equal(imex2.getdata(), numpy.array([[11, 12, 13], [14, 15, 16]])) print(imex2.statistics()) imex2.tofits('timage.py_tmp.fits') imex3 = image('timage.py_tmp.fits') print(imex3.getdata()) def test_image_coordinate(self): """Get some info on a coordinate system and change it.""" im = image("testimg", shape=[2, 2, 2, 2]) im.put(numpy.array([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]])) imcor = im.coordinates() print(im.info()) imcor.set_referencepixel([3, numpy.array([2]), numpy.array([1, 1])]) numpy.testing.assert_equal(imcor.get_referencepixel(), [3, numpy.array([2]), numpy.array([1, 1])]) self.assertIn('direction', imcor.get_names()) self.assertAlmostEqual(imcor.get_obsdate()['m0']['value'], 51544.00000000116) self.assertEqual(imcor.get_observer(), 'Karl Jansky') self.assertEqual(imcor.get_telescope(), 'ALMA') imcor.set_referencevalue([1, numpy.array([2]), numpy.array([3, 4])]) numpy.testing.assert_equal(imcor.get_referencevalue(), [1, numpy.array([2]), numpy.array([3, 4])]) imcor.set_increment([4, numpy.array([3]), numpy.array([2, 1])]) numpy.testing.assert_equal(imcor.get_increment(), [4, numpy.array([3]), numpy.array([2, 1])]) numpy.testing.assert_equal(imcor.get_axes(), ['Frequency', ['Stokes'], ['Declination', 'Right Ascension']]) print(imcor) self.assertEqual(imcor.get_unit(), ['Hz', [], ["'", "'"]]) def test_direction_coordinate(self): """Tests direction coordinates.""" im = image("testimg", shape=[2, 2, 2, 2]) imcor = im.coordinates() dircor = imcor.get_coordinate('direction') print(dircor) self.assertEqual(dircor.get_axis_size(), 2) self.assertEqual(dircor.get_image_axis(), 2) dircor.set_referencepixel([3.0, 0.0]) self.assertEqual(dircor.get_referencepixel(), [3.0, 0.0]) self.assertEqual(dircor.get_projection(), 'SIN') dircor.set_projection('TAN') self.assertEqual(dircor.get_projection(), 'TAN') self.assertEqual(dircor.get_frame(), 'J2000') dircor.set_frame('B1950') self.assertEqual(dircor.get_frame(), 'B1950') def test_spectral_coordinate(self): """Tests spectral coordinates.""" im = image("testimg", shape=[2, 2, 2, 2]) imcor = im.coordinates() spcor = imcor.get_coordinate('spectral') print (spcor) self.assertEqual(spcor.get_axis_size(), 2) self.assertEqual(spcor.get_image_axis(), 0) self.assertEqual(spcor.get_unit(), 'Hz') spcor.set_referencepixel(2) self.assertEqual(spcor.get_referencepixel(), 2) spcor.set_referencevalue(2) self.assertEqual(spcor.get_referencevalue(), 2) spcor.set_increment(3) self.assertEqual(spcor.get_increment(), 3) self.assertEqual(spcor.get_axes(), 'Frequency') spcor.set_restfrequency(1200) self.assertEqual(spcor.get_restfrequency(), 1200) self.assertEqual(spcor.get_frame(), 'LSRK') spcor.set_frame('BARY') self.assertEqual(spcor.get_frame(), 'BARY') self.assertEqual(spcor.get_conversion()['direction']['m1']['unit'], 'rad') def tests_stokes_coordinate(self): """Tests stokes coordinates.""" im = image("testimg", shape=[2, 2, 2, 2]) imcor = im.coordinates() stkco = imcor.get_coordinate('stokes') self.assertEqual(stkco.get_axis_size(), 2) self.assertEqual(stkco.get_image_axis(), 1) self.assertEqual(stkco.get_stokes(), ['I', 'Q']) # TODO # Test AttrGroup python-casacore-2.2.1/tests/test_measures.py000066400000000000000000000002161320311315100211770ustar00rootroot00000000000000import unittest2 as unittest from casacore import measures class TestMeasures(unittest.TestCase): def test_something(self): passpython-casacore-2.2.1/tests/test_quanta.py000066400000000000000000000034031320311315100206450ustar00rootroot00000000000000import unittest2 as unittest from casacore.quanta import * class TestQuanta(unittest.TestCase): def test_quanta(self): q0 = quantity('1deg') self.assertTrue(is_quantity(q0)) q1 = quantity(1.0, 'deg') self.assertTrue(is_quantity(q1)) self.assertEqual(q1, q0) q2 = quantity([180.0, 0.0], 'deg') self.assertTrue(is_quantity(q2)) self.assertNotEqual(q1, q2) self.assertEqual(str(q0+q1), '2.00000 deg') self.assertEqual(str(q0-q1), '0.00000 deg') self.assertEqual(str(q0*q1), '1.00000 deg.deg') self.assertEqual(str(q0/q1), '1.00000 deg/(deg)') self.assertEqual(str(q0+1), '2.00000 deg') self.assertEqual(str(q2+[1, 1]), '[181.00000, 1.00000] deg') print(sin(q0)) print(sin(q2)) self.assertEqual(str(q0.get()), '0.01745 rad') self.assertEqual(str(q0.get('h')), '0.06667 h') self.assertEqual(str(q0.canonical()), '0.01745 rad') self.assertEqual(str(q0.get_value()), '1.0') self.assertEqual(str(q0.get_value('arcsec')), '3600.0') self.assertEqual(q0.get_unit(), 'deg') q3 = quantity('12h10m5s') print(q3.to_time()) self.assertEqual(str(q3.to_unix_time()), '-3506672995.0') print(q3.to_angle()) self.assertEqual(q3.formatted("ANGLE"), '+182.31.15') self.assertEqual(q3.to_string("%0.3f"), '182.521 deg') q4 = quantity({'unit': 'deg', 'value': 182.52083333333334}) self.assertEqual(q3, q4) q5 = quantity(q4) self.assertEqual(q5, q4) self.assertIn('Jy', units) self.assertEqual(units['Jy'], ['jansky', quantity(1e-26, 'kg.s-2')]) self.assertIn('a', prefixes) self.assertEqual(prefixes['a'], ['atto', 1e-18]) python-casacore-2.2.1/tests/test_table.py000066400000000000000000000637051320311315100204560ustar00rootroot00000000000000"""Tests for tables module.""" import unittest2 as unittest from casacore.tables import * import numpy import collections def compare(x, y): """Unordered list compare.""" return collections.Counter(x) == collections.Counter(y) class TestTable(unittest.TestCase): """Main TestTable class.""" def test_tableinfo(self): """Test table info.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) self.assertTrue(tableexists("ttable.py_tmp.tab1")) self.assertTrue(tableiswritable("ttable.py_tmp.tab1")) self.assertEqual(t.nrows(), 0) self.assertEqual(t.ncols(), 6) self.assertTrue(compare(t.colnames(), ['cols', 'colc', 'coli', 'cold', 'colb', 'colarr'])) self.assertEqual(tableinfo("ttable.py_tmp.tab1"), {'readme': '', 'subType': '', 'type': ''}) t.addreadmeline("test table run") t.putinfo({'type': 'test', 'subType': 'test1'}) self.assertEqual(t.info()['readme'], 'test table run\n') self.assertEqual(t.info()['subType'], 'test1') self.assertEqual(t.info()['type'], 'test') self.assertEqual(len(t), 0) print(str(t)) self.assertEqual(t.endianformat(), 'little') t.close() tabledelete("ttable.py_tmp.tab1") def test_tableascii(self): """Testing ASCII table.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5)), ack=False) tcol = t.colnames() t.addrows(5) t.toascii('asciitemp1', columnnames=tcol) tablefromascii(tablename='tablefromascii', asciifile='asciitemp1') ta = table("tablefromascii", readonly=False) tacol = ta.colnames() self.assertEqual(tcol, tacol) ta.close() t.close() tabledelete('tablefromascii') tabledelete("ttable.py_tmp.tab1") def test_check_datatypes(self): """Checking datatypes.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) self.assertEqual(t.coldatatype("coli"), 'int') self.assertEqual(t.coldatatype("cold"), 'double') self.assertEqual(t.coldatatype("cols"), 'string') self.assertEqual(t.coldatatype("colb"), 'boolean') self.assertEqual(t.coldatatype("colc"), 'dcomplex') self.assertEqual(t.coldatatype("colarr"), 'double') t.close() tabledelete("ttable.py_tmp.tab1") def test_check_putdata(self): """Add rows and put data.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(2) self.assertEqual(t.nrows(), 2) numpy.testing.assert_array_equal(t.getcol('coli'), numpy.array([0, 0])) t.putcol("coli", (1, 2)) numpy.testing.assert_array_equal(t.getcol('coli'), numpy.array([1, 2])) numpy.testing.assert_array_equal( t.getcol('cold'), numpy.array([0., 0.])) t.putcol("cold", t.getcol('coli') + 3) numpy.testing.assert_array_equal( t.getcol('cold'), numpy.array([4., 5.])) t.removerows(1) self.assertEqual(t.nrows(), 1) t.close() tabledelete("ttable.py_tmp.tab1") def test_addcolumns(self): """Add columns.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(2) cd1 = makecoldesc("col2", t.getcoldesc('coli')) t.addcols(cd1) self.assertEqual(t.ncols(), 7) self.assertIn('col2', t.colnames()) t.renamecol("col2", "ncol2") self.assertNotIn('col2', t.colnames()) self.assertIn('ncol2', t.colnames()) t.close() tabledelete("ttable.py_tmp.tab1") def test_iter(self): """Testing tableiter.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(2) for iter_ in t.iter('coli', sort=False): print(iter_.getcol('coli'), iter_.rownumbers(t)) iter_.close() t.close() tabledelete("ttable.py_tmp.tab1") def test_copyandrename(self): """Copy and rename tables.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t_copy = tablecopy("ttable.py_tmp.tab1", "ttabel.tab1") self.assertEqual(t.name().split('/')[-1], 'ttable.py_tmp.tab1') self.assertEqual(t_copy.name().split('/')[-1], 'ttabel.tab1') numofrows = t.nrows() numofcols = t.ncols() self.assertEqual(t_copy.nrows(), numofrows) self.assertEqual(t_copy.ncols(), numofcols) tablerename("ttabel.tab1", "renamedttabel.tab1") self.assertEqual(t_copy.name().split('/')[-1], 'renamedttabel.tab1') t_copy.done() tabledelete("renamedttabel.tab1") t.close() tabledelete("ttable.py_tmp.tab1") def test_subset(self): """Create a subset.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t1 = t.query('coli >0', sortlist='coli desc', columns='coli,cold') querycols = t1.colnames() t1 = taql('select coli,cold from $t where coli>0 order by coli desc') taqlcol = t1.colnames() self.assertEqual(querycols, taqlcol) t1.close() t.close() tabledelete("ttable.py_tmp.tab1") def test_adddmcolumns(self): """Add some columns.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) # A scalar with the IncrementalStMan storage manager t.addcols(maketabdesc(makescacoldesc("coli2", 0)), dminfo={'TYPE': "IncrementalStMan", 'NAME': "ism1", 'SPEC': {}}) self.assertIn("coli2", t.colnames()) # An array with the StandardStMan t.addcols(maketabdesc(makearrcoldesc("colarrssm", ""))) self.assertIn("colarrssm", t.colnames()) # An array with the TiledShapeStMan t.addcols(maketabdesc(makearrcoldesc("colarrtsm", 0. + 0j, ndim=2)), dminfo={'TYPE': "TiledShapeStMan", 'NAME': "tsm1", 'SPEC': {}}) self.assertIn("colarrtsm", t.colnames()) print(t.getdminfo()) coldmi = t.getdminfo('colarrtsm') print(t.getcoldesc('colarrtsm')) coldmi["NAME"] = 'tsm2' t.addcols(maketabdesc(makearrcoldesc( "colarrtsm2", 0., ndim=2)), coldmi) self.assertEqual(t.getdminfo('colarrtsm2')["NAME"], 'tsm2') t.removecols('colarrtsm2') # Write some data. t.addrows(22) t.putcell('colarrtsm', 0, numpy.array([[1, 2, 3], [4, 5, 6]])) t.putcell('colarrtsm', 1, t.getcell('colarrtsm', 0) + 10) self.assertEqual(t.getcell('colarrtsm', 0)[1, 2], 6) print(t.getvarcol('colarrtsm')) numpy.testing.assert_array_equal(t.getcellslice('colarrtsm', 0, [1, 1], [1, 2]), numpy.array([[5. + 0.j, 6. + 0.j]])) print(t.getvarcol('colarrtsm')) t.close() tabledelete("ttable.py_tmp.tab1") def test_keywords(self): """Do keyword handling.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(2) t.putkeyword('key1', "keyval") t.putkeyword('keyrec', {'skey1': 1, 'skey2': 3.}) self.assertTrue(t._["keyrec"]['skey1'], 1) self.assertEqual(t.getkeyword('key1'), 'keyval') self.assertIn('key1', t.keywordnames()) self.assertIn('keyrec', t.keywordnames()) key1 = t.keywordnames() key2 = t.fieldnames() self.assertEqual(key1, key2) self.assertIn('skey1', t.fieldnames('keyrec')) self.assertIn('skey2', t.fieldnames('keyrec')) t.putcolkeyword('coli', 'keycoli', {'colskey': 1, 'colskey2': 3.}) self.assertEqual(t.getcolkeywords('coli')['keycoli']['colskey2'], 3) # getattr tc = t.coli self.assertEqual(tc[0], 0) self.assertEqual(t.key1, 'keyval') self.assertRaises(AttributeError, lambda: t.key2) t.removekeyword('key1') self.assertNotIn('key1', t.getcolkeywords('coli')) # Print table row # tr = t.row(['coli', 'cold') # self.assertEqual(tr[0]['coli'], 0) # # Update a few fields in the row # tr[0] = {'coli': 10, 'cold': 14} # self.assertEqual(tr[0]['coli'], 10) t.close() tabledelete("ttable.py_tmp.tab1") def test_taqlcalc(self): """Some TaQL calculations.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(2) numpy.testing.assert_array_almost_equal( t.calc("(1 km)cm"), numpy.array([100000.])) numpy.testing.assert_array_equal(t.calc("coli+1"), numpy.array([1, 1])) t.close() tabledelete("ttable.py_tmp.tab1") def test_adddata(self): """Add some more data.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(22) for i in range(2, 22): t.putcell('coli', i, i / 2) print(t[10]) t.close() tabledelete("ttable.py_tmp.tab1") def test_tablecolumn(self): """Table column.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) t.addrows(20) with tablecolumn(t, 'coli') as tc: tc[6] += 20 self.assertEqual(tc[6], 20) self.assertIn(20, tc[18:4:-2]) self.assertEqual(tc[0:][6], 20) self.assertEqual(tc.datatype(), 'int') self.assertEqual(tc.name(), 'coli') print(tc.table()) self.assertTrue(tc.isscalar()) self.assertFalse(tc.isvar()) self.assertEqual(tc.nrows(), 20) self.assertTrue(tc.iscelldefined(2)) self.assertEqual(tc.getcell(3), 0) print(tc._) self.assertEqual(tc.getcol(2, 15)[4], 20) tc.putkeyword('key1', "keyval") self.assertIn('key1', tc.keywordnames()) self.assertIn('key1', tc.fieldnames()) self.assertEqual(tc.getdesc()['dataManagerType'], 'StandardStMan') self.assertEqual(tc.getdminfo()['TYPE'], 'StandardStMan') for iter_ in tc.iter(sort=False): print(iter_[0]['coli']) self.assertEqual(len(tc), 20) self.assertEqual(tc.getkeywords()['key1'], 'keyval') numpy.testing.assert_equal(tc.getvarcol()['r1'], 0) tc.putcell(2, 55) self.assertEqual(tc[2], 55) iter_.close() t.close() tabledelete("ttable.py_tmp.tab1") def test_deletecols(self): """Delete some columns.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) a = ['colarr', 'cols', 'colb', 'colc'] t.removecols(a) self.assertNotIn(a, t.colnames()) t.close() tabledelete("ttable.py_tmp.tab1") # def test_tablerow(self): # """Testing table row.""" # c1 = makescacoldesc("coli", 0) # c2 = makescacoldesc("cold", 0.) # c3 = makescacoldesc("cols", "") # c4 = makescacoldesc("colb", True) # c5 = makescacoldesc("colc", 0. + 0j) # c6 = makearrcoldesc("colarr", 0.) # t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, # c6)), ack=False) # t.addrows(20) # with tablerow(t, 'colarr') as tr: # self.assertEqual(len(tr), 20) # print(tr[0]) # print(tr[:5]) # tr[1] = tr[0] # tr[0] = {"key": "value"} # self.assertTrue(tr.iswritable()) # t.close() # tabledelete("ttable.py_tmp.tab1") def test_subtables(self): """Testing subtables.""" c1 = makescacoldesc("coli", 0) c2 = makescacoldesc("cold", 0.) c3 = makescacoldesc("cols", "") c4 = makescacoldesc("colb", True) c5 = makescacoldesc("colc", 0. + 0j) c6 = makearrcoldesc("colarr", 0.) t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, c6)), ack=False) sub = table("sub", maketabdesc((c1, c2, c3))) t.putkeyword("subtablename", sub, makesubrecord=True) print(t.getsubtables()) t.close() tabledelete("ttable.py_tmp.tab1") # def test_tableindex(self): # """Testing table index.""" # c1 = makescacoldesc("coli", 0) # c2 = makescacoldesc("cold", 0.) # c3 = makescacoldesc("cols", "") # c4 = makescacoldesc("colb", True) # c5 = makescacoldesc("colc", 0. + 0j) # c6 = makearrcoldesc("colarr", 0.) # t = table("ttable.py_tmp.tab1", maketabdesc((c1, c2, c3, c4, c5, # c6)), ack=False) # t.addrows(20) # ti = t.index('coli') # self.assertFalse(ti.isunique()) # self.assertIn('coli', ti.colnames()) # print(ti.rownrs(23)) # print(ti.rownrs(20)) # print(ti.rownrs(2)) # print(ti.rownrs(2, 7)) # include borders # print(ti.rownrs(2, 7, False, False)) # exclude borders # t.close() # tabledelete("ttable.py_tmp.tab1") def test_msutil(self): """Testing msutil.""" datacoldesc = makearrcoldesc("DATA", 0., ndim=2, shape=[20, 4]) ms = default_ms("tabtemp", maketabdesc((datacoldesc))) ms.close() spw = table("tabtemp/SPECTRAL_WINDOW", readonly=False) spw.addrows() spw.putcell('NUM_CHAN', 0, 20) t = table("tabtemp", readonly=False) print(t.colnames()) addImagingColumns("tabtemp") self.assertIn('MODEL_DATA', t.colnames()) self.assertIn('CORRECTED_DATA', t.colnames()) self.assertIn('IMAGING_WEIGHT', t.colnames()) removeImagingColumns("tabtemp") self.assertNotIn('MODEL_DATA', t.colnames()) self.assertNotIn('CORRECTED_DATA', t.colnames()) self.assertNotIn('IMAGING_WEIGHT', t.colnames()) addDerivedMSCal("tabtemp") self.assertIn('PA1', t.colnames()) self.assertIn('PA2', t.colnames()) self.assertIn('LAST', t.colnames()) self.assertIn('AZEL2', t.colnames()) self.assertIn('AZEL1', t.colnames()) self.assertIn('UVW_J2000', t.colnames()) self.assertIn('LAST1', t.colnames()) self.assertIn('LAST2', t.colnames()) self.assertIn('HA1', t.colnames()) self.assertIn('HA2', t.colnames()) self.assertIn('HA', t.colnames()) removeDerivedMSCal("tabtemp") self.assertNotIn('PA1', t.colnames()) self.assertNotIn('PA2', t.colnames()) self.assertNotIn('LAST', t.colnames()) self.assertNotIn('AZEL2', t.colnames()) self.assertNotIn('AZEL1', t.colnames()) self.assertNotIn('UVW_J2000', t.colnames()) self.assertNotIn('LAST1', t.colnames()) self.assertNotIn('LAST2', t.colnames()) self.assertNotIn('HA1', t.colnames()) self.assertNotIn('HA2', t.colnames()) self.assertNotIn('HA', t.colnames()) self.assertNotIn('HA', t.colnames()) self.assertNotIn('HA', t.colnames()) taql("SELECT FROM tabtemp where TIME in (SELECT DISTINCT TIME" + " FROM tabtemp LIMIT 10) GIVING first10.MS AS PLAIN") taql("SELECT FROM tabtemp where TIME in (SELECT DISTINCT TIME" + " FROM tabtemp LIMIT 10 OFFSET 10) GIVING second10.MS AS PLAIN") msconcat(["first10.MS", "second10.MS"], "combined.MS", concatTime=True) spw.close() t.close() tabledelete("tabtemp") # TODO # msconcat with concatTime=False # msregularize def test_hypercolumn(self): """Test hypercolumns.""" scd1 = makescacoldesc("col2", "aa") scd2 = makescacoldesc("col1", 1, "IncrementalStMan") scd3 = makescacoldesc("colrec1", {}) acd1 = makearrcoldesc("arr1", 1, 0, [2, 3, 4]) acd2 = makearrcoldesc("arr2", 0. + 0j) td = maketabdesc([scd1, scd2, scd3, acd1, acd2]) tabledefinehypercolumn(td, "TiledArray", 4, ["arr1"]) tab = table("mytable", tabledesc=td, nrow=100) tab.done() tabledelete("mytable") def test_required_desc(self): """Testing required_desc.""" # ============================================= # TEST 1 # Create a default Measurement Set # ============================================= with default_ms("ttable.py_tmp.ms1") as ms1: pass # ============================================= # TEST 2 # Create a MS with a modified UVW column, # an additional MODEL_DATA column, as well as # specs for the column data managers # ============================================= # Get the required description for an MS ms2_desc = required_ms_desc("MAIN") # Modify UVW to use a Tiled Column Storage Manager ms2_desc["UVW"].update(options=0, shape=[3], ndim=1, dataManagerGroup="UVW", dataManagerType='TiledColumnStMan') dmgroup_spec = {"UVW": {"DEFAULTTILESHAPE": [3, 128 * 64]}} # Create an array column description # as well as a data manager group spec model_data_desc = makearrcoldesc("MODEL_DATA", 0.0, options=4, valuetype="complex", shape=[16, 4], ndim=2, datamanagertype="TiledColumnStMan", datamanagergroup="DataGroup") dmgroup_spec.update({ "DataGroup": {"DEFAULTTILESHAPE": [4, 16, 32]}}) # Incorporate column into table description ms2_desc.update(maketabdesc(model_data_desc)) # Construct a data manager info from the table description # and the data manager group spec ms2_dminfo = makedminfo(ms2_desc, dmgroup_spec) # Create measurement set with table description # and data manager info with default_ms("ttable.py_tmp.ms2", ms2_desc, ms2_dminfo) as ms2: # Check that UVW was correctly constructed desc = ms2.getcoldesc("UVW") self.assertTrue(desc["dataManagerType"] == "TiledColumnStMan") self.assertTrue(desc["dataManagerGroup"] == "UVW") self.assertTrue(desc["valueType"] == "double") self.assertTrue(desc["ndim"] == 1) self.assertTrue(np.all(desc["shape"] == [3])) dminfo = ms2.getdminfo("UVW") self.assertTrue(dminfo["NAME"] == "UVW") self.assertTrue(dminfo["TYPE"] == "TiledColumnStMan") self.assertTrue( np.all(dminfo["SPEC"]["DEFAULTTILESHAPE"] == [3, 128 * 64])) self.assertTrue(np.all(dminfo["SPEC"]["HYPERCUBES"][ "*1"]["TileShape"] == [3, 128 * 64])) self.assertTrue("MODEL_DATA" in ms2.colnames()) # Check that MODEL_DATA was correctly constructed desc = ms2.getcoldesc("MODEL_DATA") self.assertTrue(desc["dataManagerType"] == "TiledColumnStMan") self.assertTrue(desc["dataManagerGroup"] == "DataGroup") self.assertTrue(desc["valueType"] == "complex") self.assertTrue(desc["ndim"] == 2) self.assertTrue(np.all(desc["shape"] == [16, 4])) dminfo = ms2.getdminfo("MODEL_DATA") self.assertTrue(dminfo["NAME"] == "DataGroup") self.assertTrue(dminfo["TYPE"] == "TiledColumnStMan") self.assertTrue( np.all(dminfo["SPEC"]["DEFAULTTILESHAPE"] == [4, 16, 32])) self.assertTrue(np.all(dminfo["SPEC"]["HYPERCUBES"][ "*1"]["TileShape"] == [4, 16, 32])) # ============================================= # TEST 3 # Test subtable creation # ============================================= subtables = ("ANTENNA", "DATA_DESCRIPTION", "DOPPLER", "FEED", "FIELD", "FLAG_CMD", "FREQ_OFFSET", "HISTORY", "OBSERVATION", "POINTING", "POLARIZATION", "PROCESSOR", "SOURCE", "SPECTRAL_WINDOW", "STATE", "SYSCAL", "WEATHER") for c in subtables: # Check that we can get the default description for this table def_subt_desc = required_ms_desc(c) # Don't use it though (too much to check). # Rather model_data_desc = makearrcoldesc( "MODEL_DATA", 0.0, options=4, valuetype="complex", shape=[16, 4], ndim=2, datamanagertype="TiledColumnStMan", datamanagergroup="DataGroup") dmgroup_spec = {"DataGroup": {"DEFAULTTILESHAPE": [4, 16, 32]}} tabdesc = maketabdesc(model_data_desc) dminfo = makedminfo(tabdesc, dmgroup_spec) subtname = "ttable.py_tmp_subt_%s.ms" % c with default_ms_subtable(c, subtname, tabdesc, dminfo) as subt: self.assertTrue('MODEL_DATA' in subt.colnames()) dminfo = subt.getdminfo("MODEL_DATA") self.assertTrue(dminfo["NAME"] == "DataGroup") self.assertTrue(dminfo["TYPE"] == "TiledColumnStMan") self.assertTrue( np.all(dminfo["SPEC"]["DEFAULTTILESHAPE"] == [4, 16, 32])) self.assertTrue(np.all(dminfo["SPEC"]["HYPERCUBES"][ "*1"]["TileShape"] == [4, 16, 32])) python-casacore-2.2.1/tests/test_util.py000066400000000000000000000027341320311315100203370ustar00rootroot00000000000000import unittest2 as unittest from pyrap.util import substitute def f1(arg): a = 3 s = substitute('subs as $a $arg', locals=locals()) print(a, arg, s) class TestUtil(unittest.TestCase): def test_util(self): a = 1 b = 2 p = "$((a+b)*(a+b))" s = substitute(p, locals=locals()) print("a=%d, b=%d, %s => %s" % (a, b, p, s)) f1(23) f1('xyz') def test_substitute(self): a = 2 b = 3 c = "xyz" d1 = True s1 = (1, 2, 3) s2 = ['ab', 'cde', 'f', 'ghij'] self.assertTrue(substitute('$a $b $c $d1') == '2 3 "xyz" T') self.assertTrue(substitute('$(a) $(b) $(c) $(d1)') == '2 3 "xyz" T') self.assertTrue(substitute('$b $0 $a "$a" $b') == '3 $0 2 "$a" 3') self.assertTrue(substitute('$(a+b)') == '5') self.assertTrue(substitute('$((a+b)*(a+b))') == '25') self.assertTrue(substitute('$((a+b)*(a+c))') == '$((a+b)*(a+c))') self.assertTrue(substitute('"$(a+b)"') == '"$(a+b)"') self.assertTrue(substitute('\\$(a+b) \\\\$a \\$a') == '\\$(a+b) \\\\2 \\$a') self.assertTrue(substitute('$(a+b)+$a') == '5+2') self.assertTrue(substitute('$((a+b)+a)') == '7') self.assertTrue(substitute('$((a+b)*(a+b))') == '25') self.assertTrue(substitute('$(len("ab cd( de"))') == '9') self.assertTrue(substitute( ' $s1 $s2 ') == ' [1,2,3] ["ab","cde","f","ghij"] ') python-casacore-2.2.1/tests/timage.py.out000066400000000000000000000034031320311315100203710ustar00rootroot000000000000002 [4, 3] 12 12 False float Temporary_Image [[ 1. 2. 3.] [ 4. 5. 6.] [ 7. 8. 9.] [ 10. 11. 12.]] [[ 1. 2.] [ 4. 5.] [ 7. 8.]] [[ 1. 2. 3.] [ 7. 8. 9.]] [[ 2. 4. 6.] [ 8. 10. 12.] [ 14. 16. 18.] [ 20. 22. 24.]] [[ 1. 2. 3.] [ 7. 8. 9.]] [[ 2. 3. 4.] [ 4. 5. 6.] [ 8. 9. 10.] [ 10. 11. 12.]] [[False False False] [False False False] [False False False] [False False False]] [4, 6] [[ 2. 3. 4. 4. 6. 8.] [ 4. 5. 6. 8. 10. 12.] [ 8. 9. 10. 16. 18. 20.] [ 10. 11. 12. 20. 22. 24.]] [[ 2. 3. 4. 4. 6. 8.] [ 4. 5. 6. 8. 10. 12.] [ 8. 9. 10. 16. 18. 20.] [ 10. 11. 12. 20. 22. 24.]] [[ 2. 3. 4. 4. 6. 8.] [ 4. 5. 6. 8. 10. 12.] [ 8. 9. 10. 16. 18. 20.] [ 10. 11. 12. 20. 22. 24.]] [[ True True False False False False] [False False False False False False] [False False False False False False] [False False False False False False]] [[ True True False False False False] [False False False False False False] [False False False False False False] [False False False False False False]] [[ 12. 13. 14. 14. 16. 18.] [ 14. 15. 16. 18. 20. 22.] [ 18. 19. 20. 26. 28. 30.] [ 20. 21. 22. 30. 32. 34.]] {'rms': array([ 22.0608654]), 'medabsdevmed': array([ 4.]), 'minpos': array([2, 0], dtype=int32), 'min': array([ 14.]), 'max': array([ 34.]), 'sum': array([ 467.]), 'quartile': array([ 6.]), 'sumsq': array([ 10707.]), 'median': array([ 20.]), 'npts': array([ 22.]), 'maxpos': array([5, 3], dtype=int32), 'sigma': array([ 6.14841689]), 'mean': array([ 21.22727273])} [[ NaN NaN 14. 14. 16. 18.] [ 14. 15. 16. 18. 20. 22.] [ 18. 19. 20. 26. 28. 30.] [ 20. 21. 22. 30. 32. 34.]] python-casacore-2.2.1/tests/tquanta.py.out000066400000000000000000000004031320311315100205750ustar00rootroot00000000000000True True True True True 2.00000 deg 0.00000 deg 1.00000 deg.deg 1.00000 deg/(deg) 2.00000 deg [181.00000, 1.00000] deg 0.01745 [0.00000, 0.00000] 0.01745 rad 0.06667 h 0.01745 rad 1.0 3600.0 deg 0.50700 d -3506672995.0 182.52083 deg +182.31.15 182.521 deg python-casacore-2.2.1/tests/ttable.py.out000066400000000000000000000042021320311315100203740ustar00rootroot000000000000000 ['cols', 'colc', 'coli', 'cold', 'colb', 'colarr'] {} {'readme': '', 'subType': '', 'type': ''} {'readme': 'test table run\n', 'subType': '', 'type': 'test'} 2 0 ['coli', 'cold'] [ 5. 4.] ['cols', 'colc', 'coli', 'cold', 'colb', 'colarr', 'coli2'] {'*1': {'SEQNR': 0, 'TYPE': 'StandardStMan', 'NAME': 'StandardStMan', 'COLUMNS': ['colarr', 'colarrssm', 'colb', 'colc', 'cold', 'coli', 'cols'], 'SPEC': {'ActualCacheSize': 2, 'PERSCACHESIZE': 2, 'IndexLength': 0, 'BUCKETSIZE': 1540}}, '*2': {'SEQNR': 1, 'TYPE': 'IncrementalStMan', 'NAME': 'ism1', 'COLUMNS': ['coli2'], 'SPEC': {'ActualCacheSize': 1, 'PERSCACHESIZE': 1, 'BUCKETSIZE': 32768}}, '*3': {'SEQNR': 2, 'TYPE': 'TiledShapeStMan', 'NAME': 'tsm1', 'COLUMNS': ['colarrtsm'], 'SPEC': {'DEFAULTTILESHAPE': array([], dtype=int32), 'HYPERCUBES': {}, 'MAXIMUMCACHESIZE': 0, 'SEQNR': 2, 'ActualMaxCacheSize': 0, 'IndexSize': 0}}} {'comment': '', 'dataManagerType': 'TiledShapeStMan', '_c_order': True, 'option': 0, 'valueType': 'dcomplex', 'maxlen': 0, 'dataManagerGroup': 'tsm1', 'ndim': 2} {'TYPE': 'TiledShapeStMan', 'SEQNR': 3, 'NAME': 'tsm2', 'SPEC': {'DEFAULTTILESHAPE': array([], dtype=int32), 'HYPERCUBES': {}, 'MAXIMUMCACHESIZE': 0, 'SEQNR': 3, 'ActualMaxCacheSize': 0, 'IndexSize': 0}} [[[ 1.+0.j 2.+0.j 3.+0.j] [ 4.+0.j 5.+0.j 6.+0.j]] [[ 11.+0.j 12.+0.j 13.+0.j] [ 14.+0.j 15.+0.j 16.+0.j]]] [[ 5.+0.j 6.+0.j]] {'key1': 'keyval', 'keyrec': {'skey1': 1, 'skey2': 3.0}} keyval ['key1', 'keyrec'] ['key1', 'keyrec'] ['skey1', 'skey2'] {} ['coli', 'cold', 'colarrtsm'] {'colarrtsm': array([[ 1.+0.j, 2.+0.j, 3.+0.j], [ 4.+0.j, 5.+0.j, 6.+0.j]]), 'cold': 4.0, 'coli': 1} {'cold': 14.0, 'colarr': array([[ 1.+0.j, 2.+0.j, 3.+0.j], [ 4.+0.j, 5.+0.j, 6.+0.j]]), 'coli': 10} [100000.] [11 3] [1 1] [2, 3] [2 2 2] [1, 4, 5] [3 3] [6, 7] [4 4] [8, 9] [5 5] [10, 11] [6 6] [12, 13] [7 7] [14, 15] [8 8] [16, 17] [9 9] [18, 19] [10 10 10] [0, 20, 21] [9, 8, 7, 6, 5, 4, 23] [10, 2, 1, 1, 2, 2, 23, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10] False ['coli'] [6] [] [1, 4, 5] [1, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15] [7, 8, 9, 10, 11, 12, 13] [1, 4, 5, 7, 8, 9, 10, 11, 12, 13] python-casacore-2.2.1/tests/tutil.py.out000066400000000000000000000001061320311315100202610ustar00rootroot00000000000000a=1, b=2, $((a+b)*(a+b)) => 9 3 23 subs as 3 23 3 xyz subs as 3 "xyz" python-casacore-2.2.1/vagrant/000077500000000000000000000000001320311315100162435ustar00rootroot00000000000000python-casacore-2.2.1/vagrant/apt.sources.list000066400000000000000000000005671320311315100214160ustar00rootroot00000000000000deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted universe multiverse python-casacore-2.2.1/vagrant/provision.sh000066400000000000000000000010021320311315100206200ustar00rootroot00000000000000#!/bin/bash -ev export DEBIAN_FRONTEND=noninteractive ## enable wordwide mirrors and all repositories cp /vagrant/vagrant/apt.sources.list /etc/apt/sources.list ## install all requirements apt-get update apt-get install -y software-properties-common python-numpy python-nose \ python-setuptools libboost-python-dev libcfitsio3-dev \ libpython3.4-dev libpython2.7-dev python3-nose add-apt-repository ppa:radio-astro/main apt-get update apt-get install -y libcasacore2-dev