aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/utils
Commit message (Collapse)AuthorAgeFilesLines
* utils/__init__.py: Only import "setup_logging" from "logging.py"Aaron LI2016-10-291-3/+0
| | | | | | | | | | Since some modules (e.g., healpix.py) under "utils" involves Numba JIT optimization, which significantly slows the start-up speed, even some consumers (e.g., bin/fg21sim-webui) do not need them at all. Fix various import statements of other modules. NOTE: not test at the moment!
* utils/random.py: Add a note on conversion to (longitude, latitude)Aaron LI2016-10-281-0/+5
|
* utils/rotate.py: Add a new ref. which may help further vectorizationAaron LI2016-10-281-0/+2
| | | | Investigate whether the vectorization will improve the speed.
* utils/fits.py: Add parameter "checksum" for write_fits_healpix()Aaron LI2016-10-271-8/+13
| | | | Also update the docstring and one comment.
* utils/rotate.py: Fix two bugs which cause wrong resultsAaron LI2016-10-261-4/+13
| | | | | | | * Fix the wrong output shape: wrongly swap the row and column * Fix the area mapping method, which may give zero values when the index of the input is integer, which cause problem to calculate the overlapping areas.
* utils/grid.py: JIT optimize "make_grid_ellipse()"Aaron LI2016-10-261-10/+15
| | | | NOTE that the original optional paramter "rotation" is now required.
* utils/grid.py: Use own-implemented JIT-optimized "rotate_center()"Aaron LI2016-10-261-3/+3
| | | | Also remove the dependence on "scipy".
* Add utils/rotate.py: Implement basic image rotationAaron LI2016-10-261-0/+131
| | | | | | | | | The "rotate_center()" function rotates a gray-scale image by a given angle about its center, using the area mapping method or simple nearest neighbor. This function is `numba` JIT-optimized, and can replace the `scipy.ndimage.rotate()` function.
* draw.py: Remove the unused "circle()" functionAaron LI2016-10-251-42/+0
|
* draw.py: Optimize "ellipse()" using numba JITAaron LI2016-10-251-17/+27
| | | | | | | | | | NOTE: However, there are two significant problems: * Cannot figure out why ``nb.optional(nb.types.UniTuple(nb.int64, 2))`` does NOT work. Therefore, make ``shape`` as mandatory parameter instead of optional. * Cannot figure out multi-dispatch that allows both int and float types for ``r``, ``c``, ``r_radius`` and ``c_radius``. Thus only support the int type for the moment.
* draw.py: Optimize "_ellipse_in_shape()" using JITAaron LI2016-10-251-3/+20
|
* grid.py: Override "make_coordinate_grid()" using JIT-optimized versionAaron LI2016-10-251-46/+2
| | | | | Remove the original "make_coordinate_grid()" function, and rename the "make_coordinate_grid_fast()" to override the former one.
* grid.py: Change "make_coordinate_grid_fast()" parametersAaron LI2016-10-251-11/+16
| | | | | Change the parameters of "make_coordinate_grid_fast()", make it share the same parameter list as "make_coordinate_grid()".
* grid.py: Optimize "map_grid_to_healpix()" using "numba.jit"Aaron LI2016-10-251-11/+19
| | | | | There are some limitations with the numba JIT, which are commented in the code.
* healpix.py: Change all "indices" to "indexes"Aaron LI2016-10-252-19/+19
| | | | Also fix a wrong notation in "random.py"
* healpix.py: Implement "ang2pix_ring" and "pix2ang_ring" with JITAaron LI2016-10-251-0/+213
| | | | | | | | | | To optimize "map_grid_to_healpix()" in `grid.py` which uses "healpy.ang2pix()" using `numba.jit`, implement the latter's functionality explicitly with `numba.jit` support. The implementation simply mimic the corresponding functions "ang2pix_ring_z_phi()" and "pix2ang_ring_z_phi()" in HEALPix's "src/C/subs/chealpix.c". Thanks!
* healpix.py: Optimize "_calc_hpx_indicies()" and "_calc_hpx_row_idx()"_Aaron LI2016-10-251-60/+68
| | | | | Also place "_calc_hpx_row_idx()" before "_calc_hpx_indicies()", which is required by `numba`.
* utils/grid.py: Add optimized "make_coordinate_grid_fast()"Aaron LI2016-10-251-4/+56
| | | | | | | | Optimize "make_coordinate_grid()" using "numba.jit", which improves the speed a bit, since the other two functions (i.e., "make_grid_ellipse()", and "map_grid_to_healpix()") are much slow and time-consuming. TODO: optimize "make_grid_ellipse()" and "map_grid_to_healpix()"
* convert.py: Optimize "Fnu_to_Tb()" and "Sb_to_Tb()"Aaron LI2016-10-241-0/+65
| | | | | | | | | * Optimize the "Fnu_to_Tb()" and "Sb_to_Tb()" functions by explicitly calculating the conversions, avoiding the slow `astropy.unit` conversions (which is rather slow). The new fast functions are named as "Fnu_to_Tb_fast()" and "Sb_to_Tb_fast()". * Optimize the new functions using `numba.jit` further. * Add `numba` to the dependencies.
* Add utils/random.py: Custom random utilitiesAaron LI2016-10-221-0/+51
| | | | | Currently implement "spherical_uniform()" to generate random points uniformly distributed on the spherical surface.
* galactic/snr.py: Implemented missing but necessary functionalitiesAaron LI2016-10-171-1/+1
| | | | | | | | The necessary but missing functionalities to simulate the Galactic SNRs emission maps are implemented, and this new emission component is ready for testing. Also fix a typo in "utils/grid.py".
* utils/grid.py: Implement "map_grid_to_healpix()"Aaron LI2016-10-171-9/+29
| | | | | | | | The "map_grid_to_healpix()" maps the generated coordinate grid to a HEALPix map. Note that only effective HEALPix pixels are returned instead of a full HEALPix map. TODO: Try to avoid the explicit for loop to optimize the speed.
* Add utils/grid.py: Make coordinate grids for SNRsAaron LI2016-10-171-0/+157
| | | | | | | * make_coordinate_grid(): Make a Cartesian coordinate grid according to the specified center coordinate, size and grid resolution. * make_grid_ellipse(): Also generate an (rotated) ellipse and place into the coordinate grid.
* Force "DEBUG" log level if env variable "DEBUG_FG21SIM" setAaron LI2016-10-171-0/+4
|
* utils/logging.py: Small updates to the docstrings and commentsAaron LI2016-10-171-14/+16
|
* utils/draw.py: List the functions taken from "scikit-image"Aaron LI2016-10-171-2/+8
|
* Fix the reStructuredText citation syntaxAaron LI2016-10-171-1/+1
|
* utils/draw.py: Add disclaimer about the license: Modified BSDAaron LI2016-10-151-4/+41
|
* Add utils/convert.py: Implement brightness temperature conversionAaron LI2016-10-151-0/+63
|
* Add utils/draw.py: draw circles and ellipsesAaron LI2016-10-151-0/+128
| | | | | | | | | These functions will be used to draw the image of a SNR or a radio halo. These functions are copied from the `scikit-image` project. Thanks! scikit-image: http://scikit-image.org/docs/dev/api/skimage.draw.html
* utils: healpix2hpx & hpx2healpix: Remove "header" parameterAaron LI2016-10-111-35/+20
| | | | | | | | * healpix2hpx(), hpx2healpix(): Remove the "header" parameter, thus the "data" parameter can only be either the filename or a HDU; * healpix2hpx(): Remove the check on "ORDERING", since "read_fits_healpix()" always return the HEALPix data in RING ordering; * Small updates to the log messages and comments.
* utils: Update documentations, also fix stylesAaron LI2016-10-112-35/+53
|
* utils/healpix.py: log that HPX indices calculation may take a while.Aaron LI2016-10-101-0/+1
|
* utils: zea2heapix(): Set value NaN for missing pixelsAaron LI2016-10-101-5/+9
|
* utils: zea2healpix(): Implement inpainting missing pixelsAaron LI2016-10-101-3/+51
| | | | | | | The missing pixels in the reprojected HEALPix map are filled with the averages of their 8 neighboring pixels (excluding the NaN's if any). Also add the "--inpaint" argument to the executable script.
* utils: zea2healpix(): Average the duplicate pixelsAaron LI2016-10-101-2/+4
| | | | Also fix typos
* utils: zea2healpix() also return the mask arrayAaron LI2016-10-101-5/+13
| | | | | | | The mask array has values 0, 1, and 2, which indicate the different statuses of the reprojected HEALPix pixels. Also update the executable script to use the new return results.
* utils/reproject.py: Add more logging and some minor changesAaron LI2016-10-101-1/+22
|
* utils/reproject.py: Implement zea2healpix()Aaron LI2016-10-102-0/+241
| | | | | | | | | | | | | | | | The "zea2healpix()" function reprojects the maps in ZEA (zenithal/azithumal equal area) projection to HEALPix data in Galactic frame with RING ordering. The other two helper functions "_image_to_healpix()" and "_convert_wcs()" are almost copied from the "reproject" project [1]. Thanks! TODO: * Add some more logging * Implement the "inpaint" argument to inpaint the HEALPix map if exists missing pixels [1] reproject: https://github.com/astrofrog/reproject
* utils: Preseve the dtype when read/write FITS filesAaron LI2016-10-102-11/+17
| | | | | | | | * utils/fits.py: hack the dtype to ignore the byteorder (FITS data use big endianness, e.g., dtype(">f4")) * utils/healpix.py: explicit convert the dtype and log the dtype * bin/healpix2hpx, bin/hpx2healpix: remove the --float argument * other minor fixes/updates
* Use newly added "read_fits_healpix()"Aaron LI2016-10-091-3/+3
| | | | Also remove a unused variable in "galactic/synchrotron.py"
* utils/fits.py: read_fits_healpix() also accept HDUAaron LI2016-10-091-4/+9
|
* utils: Add function "read_fits_healpix()"Aaron LI2016-10-092-1/+30
| | | | | | This function wraps on the `healpy.read_map()`, but reset the data array to its original dtype in FITS file, as well as return the FITS header in `astropy.io.fits.Header` object.
* utils/healpix.py: fix logging import; minor style fixesAaron LI2016-10-091-10/+5
|
* utils: Add "write_fits_healpix()" to replace "healpy.write_map()"Aaron LI2016-10-052-0/+101
| | | | | | NOTE: This "write_fits_healpix()" function only implements the most common case of the HEALPix FITS style.
* utils/logging.py: Close handler before removingAaron LI2016-10-021-0/+3
|
* utils/logging.py: Save existing formatter for new handlersAaron LI2016-09-291-0/+5
| | | | | | | By saving the existing formatter and setting for the new handlers, the configured format styles are kept. Otherwise, the newly created handlers does not have a formatter, thus the default format style gets used.
* utils/logging: reset handlers before initialization/reconfigurationAaron LI2016-09-291-2/+9
| | | | Also improve the comments.
* utils/logging.py: Hack the "filemode" arg of "basicConfig()"Aaron LI2016-09-291-1/+4
| | | | | "logging.basicConfig()" does NOT accept parameter "filemode" if the corresponding paramter "filename" NOT specified.
* utils/healpix.py: Fix logger nameAaron LI2016-09-291-1/+1
|