Skip to content

Commit 85c2745

Browse files
Merge pull request #283 from martinkilbinger/canfar_new
Canfar new
2 parents 3dd113f + 14dbd4f commit 85c2745

File tree

71 files changed

+3029
-1923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3029
-1923
lines changed

docs/wiki/tutorial/pipeline_tutorial.md

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1. [Path variables](#path-variables)
1212
1. [Prepare input images](#prepare-input-images)
1313
1. [Select tiles](#select-tiles)
14-
1. [Download tiles and modify names](#download-tiles-and-modify-names)
14+
1. [Download tiles](#download-tiles)
1515
1. [Uncompress tile weights](#uncompress-tile-weights)
1616
1. [Process single exposure images](#process-single-exposure-images)
1717
1. [Split images](#split-images)
@@ -67,10 +67,10 @@ Naming and numbering of the input files can closely follow the original image na
6767
The pixel data can contain the observed image, a weight map, or a flag map. Tile images and weights are created in the
6868
case of CFIS by Stephen Gwyn using a combination of `swarp` and his own software. Examples of file names are
6969
`CFIS.316.246.r.fits`, `CFIS.205.267.r.weight.fits.fz`, the latter is a compressed FITS file, see below. Tile flag files
70-
are created the mask module of `ShapePipe` (see [Mask images](#mask-images)). The tile ID needs to be modified such that the `.` between the two tile numbers (RA and DEC indicator) is not mistaken for a file extension delimiter. In addition, for
70+
are created the mask module of `ShapePipe` (see [Mask images](#mask-images)). The tile ID needs to be modified such that the `.` between the two tile numbers (RA and DEC indicator) is not mistaken for a file extension delimiter. For the same reason, the extension `.fits.fz` is changed to `.fitzfz`. In addition, for
7171
clarity, we include the string `image` for a tile image type.
7272
Default convention: **<image_type>-<tile_number>.fits**
73-
Examples: `CFIS_image-277_282.fits`, `CFIS_weight-274-282.fits.fz`, `pipeline_flag-239_293.fits`
73+
Examples: `CFIS_image-277-282.fits`, `CFIS_weight-274-282.fitsfz`, `pipeline_flag-239-293.fits`
7474

7575
- Database catalogue files
7676
For very large files that combine information from multiple tiles or single exposures, `ShapePipe` creates `sqlite`
@@ -89,6 +89,9 @@ Naming and numbering of the input files can closely follow the original image na
8989
The `SETools` module that creates samples of objects according to some user-defined selection criteria (see [Select stars](#select-stars)) also outputs ASCII files with user-defined summary statistics for each CCD, for example the number of selected stars, or mean and standard deviation of their FWHM.
9090
Example: `star_stat-2366993-18.txt`
9191

92+
- tile numbers list
93+
ASCII file with a tile number on each line. Used for the `get_image_runner` module to download CFIS images (see [Download tiles](#download-tiles)).
94+
9295
- Plots
9396
The `SETools` module can also produce plots of the objects properties that were selected for a given CCD.
9497
The type of plot (histogram, scatter plot, ...) and quantities to plot as well as plot decorations can be specified in the
@@ -134,8 +137,7 @@ In `$SP_RUN` the following subdirectories need to be created by the user:
134137
- `input_tiles`: Downloaded (or symbolic links to) CFIS input tile images and weight files.
135138
- `input_exposures`: Symbolic links to CFIS single-exposure image, weight, and flag files.
136139
- `output`: General output generated by the pipeline (log files,
137-
diagnostics, statistics, output images, catalogues).
138-
- `output_headers`: Single-exposure headers with WCS information`.
140+
diagnostics, statistics, output images, catalogues, Ssingle-exposure headers with WCS information).
139141
- *Optional*: `output_star_cat`: Star catalogues, only necessary if the pipeline is run on a cluster without internet connection to access star catalogues. In that case, the star catalogues need to be retrieved outside the pipeline, for example on a login node, and copied to `output_star_cat`.
140142

141143
In general, a call to the pipeline is done as follows, after activating the `shapepipe` conda environment (indicated by `(shapepipe)` at the beginning of the shell prompt.
@@ -154,41 +156,61 @@ Before running `ShapePipe` we need to select and identify tiles and single expos
154156
The selection of images on input can be done in the config files of the relevant modules, by specifying input
155157
path(s) and input file name patterns. Either all, or a sub-selection of images in a given input directory can be selected in that way. One might want to pre-select a specific set of images, for example all available images in a given sky area. The resulting files can then be copied to a new, dedicated directory (or alternatively linked using symbolic links), or downloaded to a local machine.
156158

157-
Images can be selected to cover a given sky area, with the script `cfis_field_select`.
159+
Images can be selected to cover a given sky area, with the script `cfis_field_select`. The tile numbers is all we need here.
158160
Once we have selected the tiles, we can identify the single exposure images that were used to create those tiles, see [Fine exposures](#find-exposures).
159161

160-
For example, find the tile for a Planck cluster at R.A.=255.66 deg, dec= 34.05 deg can be found with the `--coord` option:
162+
For example, find the tile number for a Planck cluster at R.A.=255.66 deg, dec= 34.05 deg can be found with the `--coord` option:
161163
```bash
162-
cfis_field_select -i tiles+weights_DR2.txt --coord 255.66deg_34.05deg -v -t tile
164+
cfis_field_select -i tiles+weights_DR2.txt --coord 255.66deg_34.05deg -t tile --out_name_only --out_number_only -s -o tile_numbers
163165
```
164-
The input text file (with `-i`) contains a list of CFIS tiles.
166+
The input text file (with `-i`) contains a list of CFIS tiles. The tile number(s) are written as a simple list in the ASCII file `tile_numbers.txt`.
165167

166-
We also need to get the weight files for the tile.
167-
```bash
168-
cfis_field_select.py -i tiles+weights_DR2.txt --coord 255.66deg_34.05deg -v -t weight
169-
```
170168

171-
### Download tiles and modify names
169+
### Download tiles
172170

173-
The tile images and weights selected in the previous section need to be findable by `ShapePipe` in the tiles input directory `input_tiles`. Either download the images and weights there, or, if they are already stored locally on a hard disk, create symbolic links in `input_tiles`. Now is a good time to make a necessary small change to the file names. As mentioned above, any dot (`.`) that does not indicate a file extension needs to be replaced. In addition, file type specifiers need to appear before the tile number. Therefore, images and weights need to be renamed, for example according to the following scheme:
174-
```bash
175-
mv CFIS.424.248.r.fits CFIS_image_424_248.r.fits
176-
mv CFIS.424.248.r.weight.fits.fz CFIS_weight_424_248.r.weight.fits.fz
171+
**Module:** get_image_runner
172+
**Parent:** none
173+
**Input:** tile numbers list
174+
**Output:** tile image, compressed tile weight
175+
176+
The tile images and weights selected in the previous section are made available for `ShapePipe` now, by running the module `get_image_runner`. This module either downloads the images or, if they already exist on a local hard disk, creates symbolic links. Downloading uses the Virtual Observatory VOSpace (vos) software (http://www.ivoa.net/documents/VOSpace). The downloaded files (or link names) are automatically modified to be parsable by the pipeline.
177+
178+
An example config file is `SP_CONFIG/config_get_image.ini`. In the module section, we need to specify
179+
input path (for example a VOS url), input file pattern and their extension. The input file pattern includes the number(s) as dummy template, similarly to the `NUMBERING_SCHEME` in the `[FILE]` section (see `File options` in the [general pipeline readme](README.rst)). In addition, the input numbering scheme as python `regexp` needs to be specified, which matches the tile number in the tile number list.
180+
181+
Next, the output file pattern without the tile number is given.
182+
183+
After that we indicate the copy or download method, for example `vos`. Additional command options can be indicated with the key `COPY_OPTIONS`. Here is the example:
184+
```ini
185+
INPUT_PATH = vos:cfis/tiles_DR2, vos:cfis/tiles_DR2
186+
INPUT_FILE_PATTERN = CFIS.000.000.r, CFIS.000.000.r.weight
187+
INPUT_FILE_EXT = .fits, .fits.fz
188+
INPUT_NUMBERING = \d{3}\.\d{3}
189+
OUTPUT_FILE_PATTERN = CFIS_image-, CFIS_weight-
190+
COPY = vos
191+
COPY_OPTIONS = --quick
177192
```
178-
Of course the above renaming can be done at the same time as copying/creating links.
193+
194+
On success, tile images and compressed tile weights are created, either as physical files or symbolic links.
179195

180196
### Uncompress tile weights
181197

182-
The weights of the stacks are compressed .fits.fz files, they need to be uncompressed before the pipeline is run.
183-
This can be done with the script `cfis_weight_format`. For example:
198+
**Module:** uncompress_fits_images_runner
199+
**Parent:** get_image_runner
200+
**Input:** compressed tile weight
201+
**Output:** tile weight
184202

185-
```bash
186-
for fzweight in input_tiles/CFIS_weight-*.fits.fz; do
187-
weight=`basename $fzweight .fz`
188-
cfis_weight_format -i $fzweight -o input_tiles/$weight
189-
done
203+
The compressed stack weights (.fits.fz/.fitsfz files) need to be uncompressed before further processing. An example config file is `$SP_CONFIG/config_unfz_w.ini`. Except from the input file pattern and extension (see `File Options` in the [general pipeline readme](README.rst)), we need to specify the output file patern (can be the same as the input), and the HDU number of the weight image data:
204+
```ini
205+
[UNCOMPRESS_FITS_IMAGE_RUNNER]
206+
207+
FILE_PATTERN = CFIS_weight
208+
FILE_EXT = .fitsfz
209+
OUTPUT_PATTERN = CFIS_weight
210+
HDU_DATA = 1
190211
```
191212

213+
On success, the uncompressed weight image with the correct (only) HDU is written.
192214

193215
### Find exposures
194216

@@ -255,7 +277,7 @@ The example config file is `$SP_CONFIG/config_merge_headers.ini`.
255277
Specify the output path:
256278
```ini
257279
[MERGE_HEADER_RUNNER]
258-
OUTPUT_PATH = $SP_RUN/output_headers
280+
OUTPUT_PATH = $SP_RUN/output
259281
```
260282
Since this produces a single output file instead of a file per input image, it is more convenient to have this file in
261283
a separated directory for later use.
@@ -567,7 +589,7 @@ DOT_SEX_FILE = $SP_CONFIG/default_tile.sex
567589
MAKE_POST_PROCESS = TRUE
568590

569591
# Multi-epoch mode: Path to file with single-exposure WCS header information
570-
LOG_WCS = $SP_Run/output_headers/log_exp_headers.sqlite
592+
LOG_WCS = $SP_Run/output/log_exp_headers.sqlite
571593

572594
# World coordinate keywords, SExtractor output. Format: KEY_X,KEY_Y
573595
WORLD_POSITION = XWIN_WORLD, YWIN_WORLD
@@ -745,7 +767,7 @@ Here is a commented example config file for the pipeline:
745767
[NGMIX_RUNNER]
746768

747769
# Create with the split_exp_hdu module
748-
LOG_WCS = $SP_CONFIG/output_headers/log_exp_headers.npy
770+
LOG_WCS = $SP_CONFIG/output/log_exp_headers.npy
749771
```
750772

751773
### Create final catalog

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ dependencies:
1111
- pip>=19.3
1212
- pip:
1313
- modopt>=1.2
14-
- numba==0.40.0
14+
- numba>=0.49.1
1515
- sip_tpv>=1.1
1616
- sf_tools>=2.0
1717
- sqlitedict>=1.6.0
1818
- termcolor>=1.1
19-
- git+https://github.com/aguinot/ngmix@modif_observation
19+
- git+https://github.com/aguinot/ngmix@stable_version

example/GOLD/config.mask

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ MESSIER_MAKE = True
5151
MESSIER_CAT_PATH = $SP_CONFIG/mask_default/Messier_catalog_updated.npy
5252
MESSIER_PIXEL_SCALE = 0.187
5353
MESSIER_SIZE_PLUS = 0.
54-
MESSIER_FLAG_VALUE = 4
54+
MESSIER_FLAG_VALUE = 16
5555

5656

5757
# -------------------------------- External flag ----------------------------------

example/GOLD/config.mask_tile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ CDSCLIENT_PATH = findgsc2.2
1111
# ----------------------------- Border parameters ----------------------------------
1212
[BORDER_PARAMETERS]
1313

14-
BORDER_MAKE = True
14+
BORDER_MAKE = False
1515

16-
BORDER_WIDTH = 5
16+
BORDER_WIDTH = 0
1717
BORDER_FLAG_VALUE = 4
1818

1919

@@ -51,7 +51,7 @@ MESSIER_MAKE = True
5151
MESSIER_CAT_PATH = $SP_CONFIG/mask_default/Messier_catalog_updated.npy
5252
MESSIER_PIXEL_SCALE = 0.187
5353
MESSIER_SIZE_PLUS = 0.
54-
MESSIER_FLAG_VALUE = 4
54+
MESSIER_FLAG_VALUE = 16
5555

5656

5757
# -------------------------------- External flag ----------------------------------

example/GOLD/config_exp.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ MODE = SMP
3030
[FILE]
3131

3232
# Log file master name, optional, default: shapepipe
33-
LOG_NAME = log_sp_exp
33+
LOG_NAME = log_sp
3434

3535
# Runner log file name, optional, default: shapepipe_runs
36-
RUN_LOG_NAME = log_run_sp_exp
36+
RUN_LOG_NAME = log_run_sp
3737

3838
# Input directory, containing input files, single string or list of names with length matching FILE_PATTERN
39-
INPUT_DIR = $SP_RUN/input_exposures
39+
INPUT_DIR = last:get_images_runner2
4040

4141
# Output directory
4242
OUTPUT_DIR = $SP_RUN/output
@@ -87,7 +87,7 @@ FILE_EXT = .fits, .fits, .fits
8787
NUMBERING_SCHEME = -0000000-0
8888

8989
# Output path (optional)
90-
OUTPUT_PATH = $SP_RUN/output_headers
90+
OUTPUT_PATH = $SP_RUN/output
9191

9292

9393
[MASK_RUNNER]

example/GOLD/config_exp_Pi.ini

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)