diff --git a/.github/actions/run-apptainer/action.yml b/.github/actions/run-apptainer/action.yml
new file mode 100644
index 000000000..89333c560
--- /dev/null
+++ b/.github/actions/run-apptainer/action.yml
@@ -0,0 +1,52 @@
+name: 'Run ICD tests via Apptainer'
+description: 'Start carta_backend and run ICD tests'
+inputs:
+ os_version:
+ description: 'Platfrom'
+ required: true
+ image:
+ description: 'Apptainer image'
+ required: true
+ port:
+ description: 'Port number for carta_backend'
+ required: true
+ test_stage_name:
+ description: 'ICD test stage'
+ required: true
+
+runs:
+ using: 'composite'
+ steps:
+ - run: |
+ SRC_DIR=$GITHUB_WORKSPACE/source
+ BUILD_DIR=$GITHUB_WORKSPACE/build-${{ inputs.os_version }}
+ TEST_STAGE="$BUILD_DIR/ICD-RxJS/ICD_test_stages/${{ inputs.test_stage_name }}.tests"
+ LOG_FILE="/tmp/carta_icd_${{ inputs.os_version }}_${{ inputs.test_stage_name }}.log"
+ apptainer exec \
+ --bind $GITHUB_WORKSPACE:$GITHUB_WORKSPACE \
+ --bind /images:/images \
+ --pwd $BUILD_DIR \
+ ${{ inputs.image }} /bin/bash -c "\
+ # Start the carta_backend
+ ASAN_OPTIONS=suppressions=$SRC_DIR/debug/asan/myasan.supp \
+ LSAN_OPTIONS=suppressions=$SRC_DIR/debug/asan/myasan-leaks.supp \
+ ASAN_SYMBOLIZER_PATH=llvm-symbolizer \
+ ./carta_backend /images \
+ --top_level_folder /images \
+ --port ${{ inputs.port }} \
+ --omp_threads=4 \
+ --debug_no_auth \
+ --no_frontend \
+ --no_database \
+ --no_log \
+ --verbosity=5 >> $LOG_FILE 2>&1 & \
+ CARTA_BACKEND_PID=\$(pgrep -f 'carta_backend.*${{ inputs.port }}' | head -n 1) && \
+ echo 'carta_backend started with PID' \$CARTA_BACKEND_PID && \
+ # Run the ICD tests
+ cd $BUILD_DIR/ICD-RxJS && \
+ pwd && \
+ cat $TEST_STAGE && \
+ while IFS= read -r test_file || [[ -n "\$test_file" ]]; do
+ CI=true npm test -- "\$test_file"
+ done < $TEST_STAGE"
+ shell: bash
diff --git a/.github/actions/run-macos/action.yml b/.github/actions/run-macos/action.yml
new file mode 100644
index 000000000..7e6b61720
--- /dev/null
+++ b/.github/actions/run-macos/action.yml
@@ -0,0 +1,36 @@
+name: 'Run ICD tests on macOS'
+description: 'Start the carta_backend, run the ICD tests, and stop the carta_backend'
+inputs:
+ test_stage_name:
+ description: 'ICD test stage'
+ required: true
+runs:
+ using: 'composite'
+ steps:
+ - name: Start the carta-backend
+ run: |
+ SRC_DIR=$GITHUB_WORKSPACE/source
+ BUILD_DIR=$GITHUB_WORKSPACE/build
+ cd $BUILD_DIR
+ ASAN_OPTIONS=suppressions=$SRC_DIR/debug/asan/myasan.supp \
+ LSAN_OPTIONS=suppressions=$SRC_DIR/debug/asan/myasan-leaks.supp \
+ ASAN_SYMBOLIZER_PATH=llvm-symbolizer \
+ ./carta_backend /images --top_level_folder /images \
+ --port 5555 \
+ --omp_threads=4 --debug_no_auth --no_frontend --no_database --verbosity=5 &
+ echo "CARTA_BACKEND_PID=$!" >> $GITHUB_ENV
+ shell: bash
+
+ - name: ICD tests
+ run: |
+ ICD_DIR=$GITHUB_WORKSPACE/ICD-RxJS
+ cd $ICD_DIR
+ for test_file in $(cat ICD_test_stages/${{ inputs.test_stage_name }}.tests); do
+ CI=true npm test $test_file
+ sleep 3 && pgrep carta_backend
+ done
+ shell: bash
+
+ - name: Stop carta-backend
+ run: kill ${{ env.CARTA_BACKEND_PID }}
+ shell: bash
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index c7e25e414..515217888 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -9,6 +9,8 @@
- [ ] changelog updated / no changelog update needed
- [ ] e2e test passing / corresponding fix added / new e2e test created
+- [ ] ICD test passing / corresponding fix added / new ICD test created
- [ ] protobuf updated to the latest dev commit / no protobuf update needed
+- [ ] protobuf version bumped / protobuf version not bumped
- [ ] added reviewers and assignee
-- [ ] added ZenHub estimate, milestone, and release
+- [ ] GitHub Project estimate added
diff --git a/.github/workflows/icd_tests.yml b/.github/workflows/icd_tests.yml
new file mode 100644
index 000000000..26d1b9a69
--- /dev/null
+++ b/.github/workflows/icd_tests.yml
@@ -0,0 +1,1043 @@
+name: ICD tests
+on:
+ schedule:
+ - cron: '0 0 * * *' # UTC time
+env:
+ ICD_RXJS_BRANCH_NAME: dev
+
+jobs:
+
+ Build:
+ name: Build ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ path: source
+
+ - name: System information (macOS)
+ if: matrix.os == 'macos'
+ shell: bash
+ run: |
+ uname -a
+ sw_vers
+
+ - name: Build carta-backend (macOS)
+ if: matrix.os == 'macos'
+ shell: bash
+ run: |
+ SRC_DIR=$GITHUB_WORKSPACE/source
+ BUILD_DIR=$GITHUB_WORKSPACE/build
+ cd $SRC_DIR && git submodule update --init --recursive
+ rm -rf $BUILD_DIR && mkdir -p $BUILD_DIR
+ cd $BUILD_DIR
+ cmake $SRC_DIR \
+ -Dtest=on \
+ -DCMAKE_BUILD_TYPE=Debug \
+ -DDevSuppressExternalWarnings=ON \
+ -DCMAKE_CXX_FLAGS='-O0 -g -fsanitize=address -fno-omit-frame-pointer' \
+ -DCMAKE_EXE_LINKER_FLAGS='-fsanitize=address'
+ make -j 16
+
+ - name: Build carta-backend (Linux)
+ if: matrix.os == 'linux'
+ shell: bash
+ run: |
+ SRC_DIR=$GITHUB_WORKSPACE/source
+ BUILD_DIR=$GITHUB_WORKSPACE/build-${{ matrix.os_version }}
+ rm -rf $BUILD_DIR && mkdir -p $BUILD_DIR
+ cd source ; git submodule update --init --recursive
+ apptainer exec --bind $GITHUB_WORKSPACE:$GITHUB_WORKSPACE --pwd $SRC_DIR ${{ matrix.image }} /bin/bash -c "\
+ cd $BUILD_DIR && \
+ cmake $SRC_DIR \
+ -Dtest=on \
+ -DCMAKE_BUILD_TYPE=Debug \
+ -DDevSuppressExternalWarnings=ON \
+ -DCMAKE_CXX_FLAGS='-O0 -g -fsanitize=address -fno-omit-frame-pointer' \
+ -DCMAKE_EXE_LINKER_FLAGS='-fsanitize=address' && \
+ make -j 16"
+
+ - name: Check backend runs (macOS)
+ if: matrix.os == 'macos'
+ shell: bash
+ run: |
+ ./build/carta_backend --version
+
+ - name: Check backend runs (Linux)
+ if: matrix.os == 'linux'
+ shell: bash
+ run: |
+ BUILD_DIR=$GITHUB_WORKSPACE/build-${{ matrix.os_version }}
+ apptainer exec --bind $GITHUB_WORKSPACE:$GITHUB_WORKSPACE --pwd $BUILD_DIR ${{ matrix.image }} /bin/bash -c "./carta_backend --version"
+
+ Prepare-ICD-RxJS:
+ name: Prepare-ICD-RxJS ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: Build
+ steps:
+ - name: Checkout ICD-RxJS repository
+ uses: actions/checkout@v4
+ with:
+ repository: CARTAvis/ICD-RxJS
+ ref: ${{ env.ICD_RXJS_BRANCH_NAME }}
+ path: ICD-RxJS
+
+ - name: Prepare ICD-RxJS (macOS)
+ if: matrix.os == 'macos'
+ run: |
+ ICD_DIR=$GITHUB_WORKSPACE/ICD-RxJS
+ cd $ICD_DIR
+ git submodule init && git submodule update && npm install
+ cd protobuf
+ ./build_proto.sh
+ cd ../src/test
+ perl -p -i -e 's/3002/5555/' config.json
+
+ - name: Prepare ICD-RxJS (Linux)
+ if: matrix.os == 'linux'
+ run: |
+ BUILD_DIR=$GITHUB_WORKSPACE/build-${{ matrix.os_version }}
+ ICD_DIR=$GITHUB_WORKSPACE/ICD-RxJS
+ cp -r $ICD_DIR $BUILD_DIR
+ cd $BUILD_DIR/ICD-RxJS
+ git submodule update --init --recursive
+ apptainer exec --bind $GITHUB_WORKSPACE:$GITHUB_WORKSPACE --pwd $BUILD_DIR ${{ matrix.image }} /bin/bash -c "\
+ cd ICD-RxJS && \
+ npm install && \
+ cd protobuf && \
+ ./build_proto.sh && \
+ cd ../src/test && \
+ perl -p -i -e 's/3002/${{ matrix.port }}/' config.json"
+
+ File-Browser-ICD-Tests:
+ name: File-Browser ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: Prepare-ICD-RxJS
+ if: always()
+ steps:
+ # macOS steps
+ - name: File Browser ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'file_browser'
+ # Linux steps
+ - name: File Browser ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'file_browser'
+
+ Animator-ICD-Tests:
+ name: Animator ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [File-Browser-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Animator ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'animator'
+ # Linux steps
+ - name: Animator ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'animator'
+
+ Region-Statistics-ICD-Tests:
+ name: Region Statistics ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Animator-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Region-Statistics ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'region_statistics'
+ # Linux steps
+ - name: Region-Statistics ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'region_statistics'
+
+ Region-Manipulation-ICD-Tests:
+ name: Region Manipulation ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Region-Statistics-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Region Manipulation ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'region_manipulation'
+ # Linux steps
+ - name: Region Manipulation ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'region_manipulation'
+
+ Cube-Histogram-ICD-Tests:
+ name: Cube Histogram ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Region-Manipulation-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Cube Histogram ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'cube_histogram'
+ # Linux steps
+ - name: Cube Histogram ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'cube_histogram'
+
+ PV-Generator-ICD-Tests:
+ name: PV Generator ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Cube-Histogram-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: PV Generator ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'pv_generator'
+ # Linux steps
+ - name: PV Generator ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'pv_generator'
+
+ Raster-Tiles-ICD-Tests:
+ name: Raster Tiles ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [PV-Generator-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Raster Tiles ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'raster_tiles'
+ # Linux steps
+ - name: Raster Tiles ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'raster_tiles'
+
+ Catalog-ICD-Tests:
+ name: Catalog ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Raster-Tiles-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Catalog ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'catalog'
+ # Linux steps
+ - name: Catalog ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'catalog'
+
+ Moment-ICD-Tests:
+ name: Moment ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Catalog-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Moment ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'moment'
+ # Linux steps
+ - name: Moment ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'moment'
+
+ Match-ICD-Tests:
+ name: Match ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Moment-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Match ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'match'
+ # Linux steps
+ - name: Match ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'match'
+
+ Close-File-ICD-Tests:
+ name: Close File ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Match-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Close File ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'close_file'
+ # Linux steps
+ - name: Close File ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'close_file'
+
+ Image-Fitting-ICD-Tests:
+ name: Image Fitting ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Close-File-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Image Fitting ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'image_fitting'
+ # Linux steps
+ - name: Image Fitting ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'image_fitting'
+
+ Vector-Overlay-ICD-Tests:
+ name: Vector Overlay ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Image-Fitting-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Vector Overlay ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'vector_overlay'
+ # Linux steps
+ - name: Vector Overlay ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'vector_overlay'
+
+ Resume-ICD-Tests:
+ name: Resume ${{ matrix.os_version }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os_version: macOS-11
+ os: macos
+ runner: macOS-11
+ - os_version: macOS-12
+ os: macos
+ runner: [macOS-12, ICD]
+ - os_version: macOS-13
+ os: macos
+ runner: macOS-13
+ - os_version: ubuntu-20.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD1]
+ image: /opt/apptainer/ubuntu-2004-dec2023.sif
+ port: 9001
+ - os_version: ubuntu-22.04
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD2]
+ image: /opt/apptainer/ubuntu-2204-dec2023.sif
+ port: 9002
+ - os_version: rhel-7
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD3]
+ image: /opt/apptainer/centos7-dec2023.sif
+ port: 9003
+ - os_version: rhel-8
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD4]
+ image: /opt/apptainer/almalinux8-dec2023.sif
+ port: 9004
+ - os_version: rhel-9
+ os: linux
+ runner: [self-hosted, Linux, Apptainer, ICD5]
+ image: /opt/apptainer/almalinux9-dec2023.sif
+ port: 9005
+ needs: [Vector-Overlay-ICD-Tests, Prepare-ICD-RxJS]
+ if: always()
+ steps:
+ # macOS steps
+ - name: Resume ICD tests
+ if: matrix.os == 'macos'
+ uses: ./source/.github/actions/run-macos
+ with:
+ test_stage_name: 'resume'
+ # Linux steps
+ - name: Resume ICD tests
+ if: matrix.os == 'linux'
+ uses: ./source/.github/actions/run-apptainer
+ with:
+ os_version: ${{ matrix.os_version }}
+ image: ${{ matrix.image }}
+ port: ${{ matrix.port }}
+ test_stage_name: 'resume'
diff --git a/.gitignore b/.gitignore
index 242ab548d..fff4de4f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,7 @@ coverage/
# Doxygen
docs/html
+
+# Dependency download locations
+third-party/uSockets/
+third-party/uWebSockets/
diff --git a/.gitmodules b/.gitmodules
index 7613f0be7..7381ee460 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,6 @@
[submodule "carta-protobuf"]
path = carta-protobuf
url = https://github.com/CARTAvis/carta-protobuf.git
-[submodule "uWebSockets"]
- path = third-party/uWebSockets
- url = https://github.com/uNetworking/uWebSockets.git
[submodule "cxxopts"]
path = third-party/cxxopts
url = https://github.com/jarro2783/cxxopts
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62b6bd906..858141dd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,10 +4,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [4.0.0-rc.0]
+## [Unreleased]
+
+### Fixed
+* Fixed crash when loading non-image HDU by URL ([#1365](https://github.com/CARTAvis/carta-backend/issues/1365)).
+* Fix crash when parsing FITS header long value ([#1366](https://github.com/CARTAvis/carta-backend/issues/1366)).
+
+### Changed
+* Move the loader cache to separate files ([#1021](https://github.com/CARTAvis/carta-backend/issues/1021)).
+* Improve the code style in HTTP server ([#1260](https://github.com/CARTAvis/carta-backend/issues/1260)).
+* Remove program settings equality operators ([#1001](https://github.com/CARTAvis/carta-backend/issues/1001)).
+* Normalize the style of guard names in header files ([#1023](https://github.com/CARTAvis/carta-backend/issues/1023)).
+* Improved file IDs for generated images ([#1224](https://github.com/CARTAvis/carta-frontend/issues/1224)).
+* Store global settings in a singleton class ([#1302](https://github.com/CARTAvis/carta-backend/issues/1302)).
+* Move Region code to RegionConverter for maintenance and performance ([#1347](https://github.com/CARTAvis/carta-backend/issues/1347)).
+* Improve performance of region spatial profiles and PV image generation ([#1339](https://github.com/CARTAvis/carta-backend/issues/1339)).
+
+## [4.1.0]
+
+### Fixed
+* Include casacore log messages in carta log ([#1169](https://github.com/CARTAvis/carta-backend/issues/1169)).
+* Fixed the problem of opening old IRAM fits images ([#1312](https://github.com/CARTAvis/carta-backend/issues/1312)).
+* Fixed scripting interface and symlink directory issues ([#1283](https://github.com/CARTAvis/carta-frontend/issues/1283), [#1284](https://github.com/CARTAvis/carta-frontend/issues/1284), [#1314](https://github.com/CARTAvis/carta-frontend/issues/1314)).
+* Fixed incorrect std calculation when fitting images with nan values ([#1318](https://github.com/CARTAvis/carta-backend/issues/1318)).
+* Fixed the hanging problem when deleting a region during the spectral profile process ([#1328](https://github.com/CARTAvis/carta-backend/issues/1328)).
+
+### Changed
+* Updated for compatibility with latest carta-casacore using CASA 6.6.0.
+
+## [4.0.0]
### Changed
* Support animation playback with matched images in multi-panel view ([#1860](https://github.com/CARTAvis/carta-frontend/issues/1860)).
+* Update the submodule uWebSockets ([#1297](https://github.com/CARTAvis/carta-backend/issues/1297)).
### Fixed
* Prevent the installation of pugixml library files ([#1261](https://github.com/CARTAvis/carta-backend/issues/1261)).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 055645c54..ae8a92aa3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,6 +109,17 @@ endif ()
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS CXX)
FIND_PACKAGE(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
+
+if (Protobuf_VERSION VERSION_GREATER_EQUAL "4.25.3")
+ FIND_PACKAGE(absl REQUIRED)
+ set(PROTOBUF_LIBRARY
+ ${PROTOBUF_LIBRARY}
+ absl_hash
+ absl_log_internal_message
+ absl_log_internal_nullguard)
+ message(STATUS "Newer protobuf version (${Protobuf_VERSION}) includes abseil libraries")
+endif ()
+
FIND_PACKAGE(Threads)
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
@@ -192,7 +203,8 @@ set(LINK_LIBS
set(SOURCE_FILES
${SOURCE_FILES}
- third-party/pugixml/src/pugixml.cpp
+ third-party/pugixml/src/pugixml.cpp
+ src/Cache/LoaderCache.cc
src/Cache/TileCache.cc
src/Cache/TilePool.cc
src/DataStream/Compression.cc
@@ -224,6 +236,7 @@ set(SOURCE_FILES
src/ImageStats/Histogram.cc
src/ImageStats/StatsCalculator.cc
src/Logger/Logger.cc
+ src/Logger/CartaLogSink.cc
src/Main/Main.cc
src/Main/ProgramSettings.cc
src/Main/WebBrowser.cc
@@ -231,6 +244,7 @@ set(SOURCE_FILES
src/Region/Ds9ImportExport.cc
src/Region/LineBoxRegions.cc
src/Region/Region.cc
+ src/Region/RegionConverter.cc
src/Region/RegionHandler.cc
src/Region/RegionImportExport.cc
src/Session/CursorSettings.cc
diff --git a/Doxyfile b/Doxyfile
index b78869783..af087f9a7 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -1208,7 +1208,8 @@ HTML_FILE_EXTENSION = .html
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
-HTML_HEADER =
+HTML_HEADER = docs/header.html
+
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
diff --git a/carta-protobuf b/carta-protobuf
index 28f4b3a60..202c31d25 160000
--- a/carta-protobuf
+++ b/carta-protobuf
@@ -1 +1 @@
-Subproject commit 28f4b3a6008ffef35084b07ceb3e76841ca3c348
+Subproject commit 202c31d25ec4bda97cbb9bd71fee589541872847
diff --git a/docs/header.html b/docs/header.html
new file mode 100644
index 000000000..add8aa93d
--- /dev/null
+++ b/docs/header.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+$projectname: $title
+$title
+
+
+
+
+
+
+
+
+
+$treeview
+$search
+$mathjax
+
+$extrastylesheet
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $projectname $projectnumber
+
+ $projectbrief
+
+
+
+
+
+ $projectbrief
+
+
+
+
+
+
+ $searchbox
+
+
+
+
+
+
+ $searchbox
+
+
+
+
+
+
+
diff --git a/docs/static/main.md b/docs/static/main.md
index 85bfb9e7d..839317b37 100644
--- a/docs/static/main.md
+++ b/docs/static/main.md
@@ -7,6 +7,7 @@ Documentation for other CARTA components
----------------------------------------
* [CARTA user manual](https://carta.readthedocs.io) (for users)
-* %CARTA frontend (TBD)
+* [CARTA frontend](https://cartavis.org/carta-frontend/) (for developers)
+* [CARTA interface control document](https://carta-protobuf.readthedocs.io) (for developers)
* [CARTA controller](https://carta-controller.readthedocs.io) (for system administrators)
* [CARTA Python scripting wrapper](https://carta-python.readthedocs.io) (for users of the scripting interface)
diff --git a/scripts/carta b/scripts/carta
index 4764a3ac6..d37937e75 100755
--- a/scripts/carta
+++ b/scripts/carta
@@ -11,8 +11,10 @@ if [ ! -z $FIRST_IP ]; then
export SERVER_IP=$FIRST_IP
fi
-if [ -x "$(command -v casa_data_autoupdate)" ]; then
- casa_data_autoupdate
+if [[ ! " $@ " =~ ( --version | -v | --help | -h ) ]]; then
+ if [ -x "$(command -v casa_data_autoupdate)" ]; then
+ casa_data_autoupdate
+ fi
fi
carta_backend "$@"
diff --git a/scripts/style.py b/scripts/style.py
index 643ca3d9a..2e24f7446 100755
--- a/scripts/style.py
+++ b/scripts/style.py
@@ -3,6 +3,7 @@
import sys
import os
import re
+import glob
import argparse
import subprocess
@@ -11,8 +12,7 @@ class Test:
TESTS = {}
EXCLUDE_FROM_ALL = False
- EXTENSIONS = ("cc", "h", "tcc")
- FILE_REGEX = fr".*\.({'|'.join(EXTENSIONS)})$"
+ EXTENSIONS = {"cc", "h", "tcc"}
quiet = False
out = print
@@ -29,11 +29,13 @@ def get_tests(cls, testname):
return (cls.TESTS[testname],)
@classmethod
- def cpp_files(cls, directory):
+ def cpp_files(cls, directory, exclude=set()):
+ FILE_REGEX = fr".*\.({'|'.join(cls.EXTENSIONS - exclude)})$"
+
for root, dirs, files in os.walk(directory):
dirs[:] = [d for d in dirs]
for basename in files:
- if re.match(cls.FILE_REGEX, basename):
+ if re.match(FILE_REGEX, basename):
filename = os.path.join(root, basename)
yield filename
@@ -48,7 +50,7 @@ def fix(cls, directories):
class Header(Test):
HEADER = """/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -184,6 +186,96 @@ def fix(cls, directories):
return 0
+class HeaderGuards(Test):
+ IFNDEF_REGEX = re.compile("^#ifndef ([A-Z_0-9]*_(H|TCC)_*)$", flags=re.MULTILINE)
+ LAST_ENDIF_REGEX = re.compile(r"^(#endif[^\n]*?)\n$(?!.*#endif)", flags=re.MULTILINE|re.DOTALL)
+
+ @classmethod
+ def make_guard_name(cls, filename):
+ name = re.sub('[/.$]', '_', filename).upper()
+ return f"CARTA_{name}_"
+
+ @classmethod
+ def make_endif(cls, name):
+ return f"#endif // {name}"
+
+ @classmethod
+ def check(cls, directories):
+ status = 0
+
+ for directory in directories:
+ for filename in cls.cpp_files(directory, exclude={"cc"}):
+ with open(filename) as f:
+ data = f.read()
+
+ new_guard_name = cls.make_guard_name(filename)
+
+ m = cls.IFNDEF_REGEX.search(data)
+
+ if m is None:
+ cls.out("Can't find header guard in", filename)
+ status = 1
+ else:
+
+ existing_guard_name = m.group(1)
+
+ if new_guard_name != existing_guard_name:
+ cls.out("Bad header guard in", filename)
+ status = 1
+
+ last_endif = cls.LAST_ENDIF_REGEX.search(data).group(1)
+ if last_endif != cls.make_endif(existing_guard_name):
+ cls.out("Mismatched header guard #endif comment in", filename)
+ status = 1
+
+ return status
+
+ @classmethod
+ def fix(cls, directories):
+ for directory in directories:
+ for filename in cls.cpp_files(directory, exclude={"cc"}):
+ with open(filename) as f:
+ data = f.read()
+
+ new_guard_name = cls.make_guard_name(filename)
+ new_endif = cls.make_endif(new_guard_name)
+ data_changed = False
+
+ m = cls.IFNDEF_REGEX.search(data)
+
+ if m is None:
+ cls.out("Can't find header guard in", filename)
+ cls.out("Fixing...")
+
+ data = re.sub("(/\*.*?\*/\n)", rf"\1\n#ifndef {new_guard_name}\n#define {new_guard_name}\n", data, count=1, flags=re.DOTALL)
+ data = re.sub(r"\n$", rf"\n{new_endif}\n", data)
+ data_changed = True
+
+ else:
+ existing_guard_name = m.group(1)
+
+ if new_guard_name != existing_guard_name:
+ cls.out("Bad header guard in", filename)
+ cls.out("Fixing...")
+
+ data = re.sub(existing_guard_name, new_guard_name, data)
+ data_changed = True
+
+ last_endif = cls.LAST_ENDIF_REGEX.search(data).group(1)
+ if last_endif != new_endif:
+ cls.out("Mismatched header guard #endif comment in", filename)
+ cls.out("Fixing...")
+
+ data = cls.LAST_ENDIF_REGEX.sub(rf"{new_endif}\n", data)
+ data_changed = True
+
+ if data_changed:
+ with open(filename, "w") as f:
+ f.write(data)
+
+ return 0
+
+
class Style(Test):
EXCLUDE_FROM_ALL = True
diff --git a/src/Cache/LoaderCache.cc b/src/Cache/LoaderCache.cc
new file mode 100644
index 000000000..f06cd59e9
--- /dev/null
+++ b/src/Cache/LoaderCache.cc
@@ -0,0 +1,63 @@
+/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
+ SPDX-License-Identifier: GPL-3.0-or-later
+*/
+
+#include "LoaderCache.h"
+
+#include "Logger/Logger.h"
+
+using namespace carta;
+
+LoaderCache::LoaderCache(int capacity) : _capacity(capacity){};
+
+std::shared_ptr
LoaderCache::Get(const std::string& filename, const std::string& directory) {
+ std::unique_lock guard(_loader_cache_mutex);
+ auto key = GetKey(filename, directory);
+
+ // We have a cached loader, but the file has changed
+ if ((_map.find(key) != _map.end()) && _map[key] && _map[key]->ImageUpdated()) {
+ _map.erase(key);
+ _queue.remove(key);
+ }
+
+ // We don't have a cached loader
+ if (_map.find(key) == _map.end()) {
+ // Create the loader -- don't block while doing this
+ std::shared_ptr loader_ptr;
+ guard.unlock();
+ loader_ptr = std::shared_ptr(FileLoader::GetLoader(filename, directory));
+ guard.lock();
+
+ // Check if the loader was added in the meantime
+ if (_map.find(key) == _map.end()) {
+ // Evict oldest loader if necessary
+ if (_map.size() == _capacity) {
+ _map.erase(_queue.back());
+ _queue.pop_back();
+ }
+
+ // Insert the new loader
+ _map[key] = loader_ptr;
+ _queue.push_front(key);
+ }
+ } else {
+ // Touch the cache entry
+ _queue.remove(key);
+ _queue.push_front(key);
+ }
+
+ return _map[key];
+}
+
+void LoaderCache::Remove(const std::string& filename, const std::string& directory) {
+ std::unique_lock guard(_loader_cache_mutex);
+ auto key = GetKey(filename, directory);
+ _map.erase(key);
+ _queue.remove(key);
+}
+
+std::string LoaderCache::GetKey(const std::string& filename, const std::string& directory) {
+ return (directory.empty() ? filename : fmt::format("{}/{}", directory, filename));
+}
diff --git a/src/Cache/LoaderCache.h b/src/Cache/LoaderCache.h
new file mode 100644
index 000000000..63b8c723d
--- /dev/null
+++ b/src/Cache/LoaderCache.h
@@ -0,0 +1,35 @@
+/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
+ SPDX-License-Identifier: GPL-3.0-or-later
+*/
+
+#ifndef CARTA_SRC_CACHE_LOADERCACHE_H_
+#define CARTA_SRC_CACHE_LOADERCACHE_H_
+
+#include
+#include
+#include
+
+#include "ImageData/FileLoader.h"
+
+namespace carta {
+
+// Cache of loaders for reading images from disk.
+class LoaderCache {
+public:
+ LoaderCache(int capacity);
+ std::shared_ptr Get(const std::string& filename, const std::string& directory = "");
+ void Remove(const std::string& filename, const std::string& directory = "");
+
+private:
+ std::string GetKey(const std::string& filename, const std::string& directory);
+ int _capacity;
+ std::unordered_map> _map;
+ std::list _queue;
+ std::mutex _loader_cache_mutex;
+};
+
+} // namespace carta
+
+#endif // CARTA_SRC_CACHE_LOADERCACHE_H_
diff --git a/src/Cache/RequirementsCache.h b/src/Cache/RequirementsCache.h
index b72a09275..1fa771842 100644
--- a/src/Cache/RequirementsCache.h
+++ b/src/Cache/RequirementsCache.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__REQUIREMENTSCACHE_H_
-#define CARTA_BACKEND__REQUIREMENTSCACHE_H_
+#ifndef CARTA_SRC_CACHE_REQUIREMENTSCACHE_H_
+#define CARTA_SRC_CACHE_REQUIREMENTSCACHE_H_
#include "ImageStats/BasicStatsCalculator.h"
#include "ImageStats/Histogram.h"
@@ -223,4 +223,4 @@ struct StatsCache {
} // namespace carta
-#endif // CARTA_BACKEND__REQUIREMENTSCACHE_H_
+#endif // CARTA_SRC_CACHE_REQUIREMENTSCACHE_H_
diff --git a/src/Cache/TileCache.cc b/src/Cache/TileCache.cc
index cf0f942e2..60b594730 100644
--- a/src/Cache/TileCache.cc
+++ b/src/Cache/TileCache.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/Cache/TileCache.h b/src/Cache/TileCache.h
index 0f026b53c..d0f34753e 100644
--- a/src/Cache/TileCache.h
+++ b/src/Cache/TileCache.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__TILE_CACHE_H_
-#define CARTA_BACKEND__TILE_CACHE_H_
+#ifndef CARTA_SRC_CACHE_TILECACHE_H_
+#define CARTA_SRC_CACHE_TILECACHE_H_
#include
#include
@@ -115,4 +115,4 @@ class TileCache {
} // namespace carta
-#endif // CARTA_BACKEND__TILE_CACHE_H_
+#endif // CARTA_SRC_CACHE_TILECACHE_H_
diff --git a/src/Cache/TileCacheKey.h b/src/Cache/TileCacheKey.h
index f09db272f..a904eb3af 100644
--- a/src/Cache/TileCacheKey.h
+++ b/src/Cache/TileCacheKey.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_TILECACHEKEY_H
-#define CARTA_BACKEND_TILECACHEKEY_H
+#ifndef CARTA_SRC_CACHE_TILECACHEKEY_H_
+#define CARTA_SRC_CACHE_TILECACHEKEY_H_
namespace carta {
/** @brief Key for tiles used in TileCache
@@ -54,4 +54,4 @@ struct hash {
};
} // namespace std
-#endif // CARTA_BACKEND_TILECACHEKEY_H
+#endif // CARTA_SRC_CACHE_TILECACHEKEY_H_
diff --git a/src/Cache/TilePool.cc b/src/Cache/TilePool.cc
index 2cdf2f68e..c16bac39b 100644
--- a/src/Cache/TilePool.cc
+++ b/src/Cache/TilePool.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/Cache/TilePool.h b/src/Cache/TilePool.h
index 2192e085d..b1a2a33bc 100644
--- a/src/Cache/TilePool.h
+++ b/src/Cache/TilePool.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_TILEPOOL_H
-#define CARTA_BACKEND_TILEPOOL_H
+#ifndef CARTA_SRC_CACHE_TILEPOOL_H_
+#define CARTA_SRC_CACHE_TILEPOOL_H_
#include
#include
@@ -80,4 +80,4 @@ struct TilePool : std::enable_shared_from_this {
} // namespace carta
-#endif // CARTA_BACKEND_TILEPOOL_H
+#endif // CARTA_SRC_CACHE_TILEPOOL_H_
diff --git a/src/DataStream/Compression.cc b/src/DataStream/Compression.cc
index ef28794f4..45b2da924 100644
--- a/src/DataStream/Compression.cc
+++ b/src/DataStream/Compression.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/DataStream/Compression.h b/src/DataStream/Compression.h
index 15984e46f..2d3c15944 100644
--- a/src/DataStream/Compression.h
+++ b/src/DataStream/Compression.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__COMPRESSION_H_
-#define CARTA_BACKEND__COMPRESSION_H_
+#ifndef CARTA_SRC_DATASTREAM_COMPRESSION_H_
+#define CARTA_SRC_DATASTREAM_COMPRESSION_H_
#include
#include
@@ -24,4 +24,4 @@ void EncodeIntegers(std::vector& array, bool strided = false);
} // namespace carta
-#endif // CARTA_BACKEND__COMPRESSION_H_
+#endif // CARTA_SRC_DATASTREAM_COMPRESSION_H_
diff --git a/src/DataStream/Contouring.cc b/src/DataStream/Contouring.cc
index a4c72e6d6..17f262380 100644
--- a/src/DataStream/Contouring.cc
+++ b/src/DataStream/Contouring.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/DataStream/Contouring.h b/src/DataStream/Contouring.h
index e9cf4fc31..7362f4281 100644
--- a/src/DataStream/Contouring.h
+++ b/src/DataStream/Contouring.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__CONTOURING_H_
-#define CARTA_BACKEND__CONTOURING_H_
+#ifndef CARTA_SRC_DATASTREAM_CONTOURING_H_
+#define CARTA_SRC_DATASTREAM_CONTOURING_H_
#include
#include
@@ -25,4 +25,4 @@ void TraceContours(float* image, int64_t width, int64_t height, double scale, do
} // namespace carta
-#endif // CARTA_BACKEND__CONTOURING_H_
+#endif // CARTA_SRC_DATASTREAM_CONTOURING_H_
diff --git a/src/DataStream/Smoothing.cc b/src/DataStream/Smoothing.cc
index ff343e8a8..96dd69732 100644
--- a/src/DataStream/Smoothing.cc
+++ b/src/DataStream/Smoothing.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/DataStream/Smoothing.h b/src/DataStream/Smoothing.h
index 9821545c8..453c3f04c 100644
--- a/src/DataStream/Smoothing.h
+++ b/src/DataStream/Smoothing.h
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -8,8 +8,8 @@
// Created by angus on 2019/09/23.
//
-#ifndef CARTA_BACKEND__SMOOTHING_H_
-#define CARTA_BACKEND__SMOOTHING_H_
+#ifndef CARTA_SRC_DATASTREAM_SMOOTHING_H_
+#define CARTA_SRC_DATASTREAM_SMOOTHING_H_
#include
#include
@@ -77,4 +77,4 @@ void NearestNeighbor(const float* src_data, float* dest_data, int64_t src_width,
} // namespace carta
-#endif // CARTA_BACKEND__SMOOTHING_H_
+#endif // CARTA_SRC_DATASTREAM_SMOOTHING_H_
diff --git a/src/DataStream/Tile.cc b/src/DataStream/Tile.cc
index 6e3453f6b..4c2a0b885 100644
--- a/src/DataStream/Tile.cc
+++ b/src/DataStream/Tile.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/DataStream/Tile.h b/src/DataStream/Tile.h
index dfef64aa3..6dcdca1db 100644
--- a/src/DataStream/Tile.h
+++ b/src/DataStream/Tile.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__TILE_H_
-#define CARTA_BACKEND__TILE_H_
+#ifndef CARTA_SRC_DATASTREAM_TILE_H_
+#define CARTA_SRC_DATASTREAM_TILE_H_
#include
#include
@@ -52,4 +52,4 @@ struct Tile {
} // namespace carta
-#endif // CARTA_BACKEND__TILE_H_
+#endif // CARTA_SRC_DATASTREAM_TILE_H_
diff --git a/src/DataStream/VectorField.cc b/src/DataStream/VectorField.cc
index e447130e2..953083ab0 100644
--- a/src/DataStream/VectorField.cc
+++ b/src/DataStream/VectorField.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/DataStream/VectorField.h b/src/DataStream/VectorField.h
index e49b69789..7afa2c0e0 100644
--- a/src/DataStream/VectorField.h
+++ b/src/DataStream/VectorField.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__FRAME_VECTORFIELD_H_
-#define CARTA_BACKEND__FRAME_VECTORFIELD_H_
+#ifndef CARTA_SRC_DATASTREAM_VECTORFIELD_H_
+#define CARTA_SRC_DATASTREAM_VECTORFIELD_H_
#include
#include
@@ -138,4 +138,4 @@ CARTA::ImageBounds GetImageBounds(const carta::Tile& tile, int image_width, int
} // namespace carta
-#endif // CARTA_BACKEND__FRAME_VECTORFIELD_H_
+#endif // CARTA_SRC_DATASTREAM_VECTORFIELD_H_
diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc
index 4172aeddd..85c01f61b 100644
--- a/src/FileList/FileExtInfoLoader.cc
+++ b/src/FileList/FileExtInfoLoader.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h
index 1ebc3255e..9ce5d1eb0 100644
--- a/src/FileList/FileExtInfoLoader.h
+++ b/src/FileList/FileExtInfoLoader.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# FileExtInfoLoader.h: load FileInfoExtended fields for all supported file types
-#ifndef CARTA_BACKEND__FILELIST_FILEEXTINFOLOADER_H_
-#define CARTA_BACKEND__FILELIST_FILEEXTINFOLOADER_H_
+#ifndef CARTA_SRC_FILELIST_FILEEXTINFOLOADER_H_
+#define CARTA_SRC_FILELIST_FILEEXTINFOLOADER_H_
#include
#include
@@ -79,4 +79,4 @@ class FileExtInfoLoader {
} // namespace carta
-#endif // CARTA_BACKEND__FILELIST_FILEINFOLOADER_H_
+#endif // CARTA_SRC_FILELIST_FILEEXTINFOLOADER_H_
diff --git a/src/FileList/FileInfoLoader.cc b/src/FileList/FileInfoLoader.cc
index f0b1f93c7..8107fe384 100644
--- a/src/FileList/FileInfoLoader.cc
+++ b/src/FileList/FileInfoLoader.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/FileList/FileInfoLoader.h b/src/FileList/FileInfoLoader.h
index 0559817d9..b84fc7a37 100644
--- a/src/FileList/FileInfoLoader.h
+++ b/src/FileList/FileInfoLoader.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# FileInfoLoader.h: load FileInfo fields for given file
-#ifndef CARTA_BACKEND__FILELIST_FILEINFOLOADER_H_
-#define CARTA_BACKEND__FILELIST_FILEINFOLOADER_H_
+#ifndef CARTA_SRC_FILELIST_FILEINFOLOADER_H_
+#define CARTA_SRC_FILELIST_FILEINFOLOADER_H_
#include
@@ -32,4 +32,4 @@ class FileInfoLoader {
} // namespace carta
-#endif // CARTA_BACKEND__FILELIST_FILEINFOLOADER_H_
+#endif // CARTA_SRC_FILELIST_FILEINFOLOADER_H_
diff --git a/src/FileList/FileListHandler.cc b/src/FileList/FileListHandler.cc
index 2a02b9ec9..62a4ac4f5 100644
--- a/src/FileList/FileListHandler.cc
+++ b/src/FileList/FileListHandler.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -55,6 +55,9 @@ void FileListHandler::GetRelativePath(std::string& folder) {
folder = folder.substr(1); // remove leading '/'
}
}
+ if (folder.empty()) {
+ folder = ".";
+ }
}
void FileListHandler::GetFileList(CARTA::FileListResponse& file_list_response, const std::string& folder, ResultMsg& result_msg,
@@ -72,65 +75,51 @@ void FileListHandler::GetFileList(CARTA::FileListResponse& file_list_response, c
requested_folder = folder_string;
}
- std::string absolute_path(requested_folder), directory;
-
- if (requested_folder == _top_level_folder) {
- // Set directory relative to top (current directory). Parent is empty string.
- file_list_response.set_directory(".");
- } else {
- // Normalize folder relative to top, restore path
- GetRelativePath(requested_folder);
- casacore::Path path(_top_level_folder);
- path.append(requested_folder);
-
- // Resolve path (., .., ~, symlinks)
- try {
- absolute_path = path.resolvedName();
- } catch (casacore::AipsError& err) {
- try {
- absolute_path = path.absoluteName();
- } catch (casacore::AipsError& err) {
- file_list_response.set_success(false);
- file_list_response.set_message("Cannot resolve directory path for file list.");
- return;
- }
- }
+ // Normalize requested folder relative to top (top + requested = full path)
+ GetRelativePath(requested_folder);
- // Set parent relative to top
- std::string parent(path.dirName());
- GetRelativePath(parent);
- file_list_response.set_parent(parent);
+ // Resolve path (., .., ~, symlinks)
+ std::string message;
+ auto resolved_path = GetResolvedFilename(_top_level_folder, requested_folder, "", message);
- // Set directory relative to top
- directory = absolute_path;
- GetRelativePath(directory);
- file_list_response.set_directory(directory);
+ // Check resolved path
+ if (resolved_path.empty()) {
+ file_list_response.set_success(false);
+ file_list_response.set_message("File list failed: " + message);
+ return;
+ } else if ((_top_level_folder.find(resolved_path) == 0) && (resolved_path.length() < _top_level_folder.length())) {
+ // path is above top folder!
+ file_list_response.set_success(false);
+ file_list_response.set_message("Forbidden path.");
+ return;
}
- if ((_top_level_folder.find(absolute_path) == 0) && (absolute_path.length() < _top_level_folder.length())) {
- // absolute path is above top folder
+ casacore::File folder_path(resolved_path);
+ if (!folder_path.isDirectory()) {
file_list_response.set_success(false);
- file_list_response.set_message("Forbidden path.");
+ file_list_response.set_message("File list failed: requested path " + folder + " is not a directory.");
return;
}
- casacore::File folder_path(absolute_path);
- std::string message;
+ // Set response parent and directory
+ if (requested_folder == ".") {
+ // is top folder; no directory
+ file_list_response.set_parent(requested_folder);
+ } else {
+ // Make full path to separate directory and base names
+ casacore::Path full_path(_top_level_folder);
+ full_path.append(requested_folder);
+ // parent
+ std::string parent(full_path.dirName());
+ GetRelativePath(parent);
+ file_list_response.set_parent(parent);
+ // directory
+ std::string directory(full_path.baseName());
+ file_list_response.set_directory(requested_folder);
+ }
+ // Iterate through directory to generate file list
try {
- if (!folder_path.exists()) {
- file_list_response.set_success(false);
- file_list_response.set_message("Requested directory " + directory + " does not exist.");
- return;
- }
-
- if (!folder_path.isDirectory()) {
- file_list_response.set_success(false);
- file_list_response.set_message("Requested path " + directory + " is not a directory.");
- return;
- }
-
- // Iterate through directory to generate file list
casacore::Directory start_dir(folder_path);
casacore::DirectoryIterator dir_iter(start_dir);
@@ -326,37 +315,38 @@ bool FileListHandler::FillRegionFileInfo(
void FileListHandler::OnRegionFileInfoRequest(
const CARTA::RegionFileInfoRequest& request, CARTA::RegionFileInfoResponse& response, ResultMsg& result_msg) {
// Fill response message with file info and contents
- casacore::Path top_path(_top_level_folder);
- top_path.append(request.directory());
- auto filename = request.file();
- top_path.append(filename);
- casacore::File cc_file(top_path);
- std::string message, contents;
- bool success(false);
+ auto directory = request.directory();
+ auto file = request.file();
+ std::string message;
- if (!cc_file.exists()) {
- message = "File " + filename + " does not exist.";
- response.add_contents(contents);
- } else if (!cc_file.isRegular(true)) {
- message = "File " + filename + " is not a region file.";
- response.add_contents(contents);
- } else if (!cc_file.isReadable()) {
- message = "File " + filename + " is not readable.";
- response.add_contents(contents);
- } else {
- casacore::String full_name(cc_file.path().resolvedName());
- auto& file_info = *response.mutable_file_info();
- FillRegionFileInfo(file_info, full_name);
- std::vector file_contents;
- if (file_info.type() == CARTA::FileType::UNKNOWN) {
- message = "File " + filename + " is not a region file.";
- response.add_contents(contents);
+ casacore::String full_name = GetResolvedFilename(_top_level_folder, directory, file, message);
+
+ bool success(false), add_contents(true);
+ if (!full_name.empty()) {
+ casacore::File cc_file(full_name);
+ if (!cc_file.isRegular(true)) {
+ message = "File " + file + " is not a region file.";
} else {
- GetRegionFileContents(full_name, file_contents);
- success = true;
- *response.mutable_contents() = {file_contents.begin(), file_contents.end()};
+ auto& file_info = *response.mutable_file_info();
+ FillRegionFileInfo(file_info, full_name);
+
+ if (file_info.type() == CARTA::FileType::UNKNOWN) {
+ message = "File " + file + " is not a region file.";
+ } else {
+ std::vector file_contents;
+ GetRegionFileContents(full_name, file_contents);
+ success = true;
+ *response.mutable_contents() = {file_contents.begin(), file_contents.end()};
+ add_contents = false;
+ }
}
}
+
+ if (add_contents) {
+ std::string contents;
+ response.add_contents(contents);
+ }
+
response.set_success(success);
response.set_message(message);
}
diff --git a/src/FileList/FileListHandler.h b/src/FileList/FileListHandler.h
index 2729e4bac..e0a4aaf63 100644
--- a/src/FileList/FileListHandler.h
+++ b/src/FileList/FileListHandler.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
// file list handler for all users' requests
-#ifndef CARTA_BACKEND__FILELISTHANDLER_H_
-#define CARTA_BACKEND__FILELISTHANDLER_H_
+#ifndef CARTA_SRC_FILELIST_FILELISTHANDLER_H_
+#define CARTA_SRC_FILELIST_FILELISTHANDLER_H_
#include
#include
@@ -69,4 +69,4 @@ class FileListHandler {
} // namespace carta
-#endif // CARTA_BACKEND__FILELISTHANDLER_H_
+#endif // CARTA_SRC_FILELIST_FILELISTHANDLER_H_
diff --git a/src/FileList/FitsHduList.cc b/src/FileList/FitsHduList.cc
index 7b8c0ddf1..52a259dd4 100644
--- a/src/FileList/FitsHduList.cc
+++ b/src/FileList/FitsHduList.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/FileList/FitsHduList.h b/src/FileList/FitsHduList.h
index 73af080d1..5717150f7 100644
--- a/src/FileList/FitsHduList.h
+++ b/src/FileList/FitsHduList.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_FILELIST_FITSHDULIST_H_
-#define CARTA_BACKEND_FILELIST_FITSHDULIST_H_
+#ifndef CARTA_SRC_FILELIST_FITSHDULIST_H_
+#define CARTA_SRC_FILELIST_FITSHDULIST_H_
#include
#include
@@ -27,4 +27,4 @@ class FitsHduList {
} // namespace carta
-#endif // CARTA_BACKEND_FILELIST_FITSHDULIST_H_
+#endif // CARTA_SRC_FILELIST_FITSHDULIST_H_
diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc
index bfc73f401..bfdfb1acc 100644
--- a/src/Frame/Frame.cc
+++ b/src/Frame/Frame.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -182,6 +182,11 @@ int Frame::StokesAxis() {
return _stokes_axis;
}
+bool Frame::IsCurrentZStokes(const StokesSource& stokes_source) {
+ return (stokes_source.z_range.from == stokes_source.z_range.to) && (stokes_source.z_range.from == CurrentZ()) &&
+ (stokes_source.stokes == CurrentStokes());
+}
+
bool Frame::GetBeams(std::vector& beams) {
std::string error;
bool beams_ok = _loader->GetBeams(beams, error);
@@ -331,12 +336,12 @@ bool Frame::SetImageChannels(int new_z, int new_stokes, std::string& message) {
bool z_ok(CheckZ(new_z));
bool stokes_ok(CheckStokes(new_stokes));
if (z_ok && stokes_ok) {
- _z_index = new_z;
- _stokes_index = new_stokes;
-
// invalidate the image cache
InvalidateImageCache();
+ _z_index = new_z;
+ _stokes_index = new_stokes;
+
if (!(_loader->UseTileCache() && _loader->HasMip(2)) || IsComputedStokes(_stokes_index)) {
// Reload the full channel cache for loaders which use it
FillImageCache();
@@ -366,7 +371,6 @@ bool Frame::SetCursor(float x, float y) {
bool Frame::FillImageCache() {
// get image data for z, stokes
-
bool write_lock(true);
queuing_rw_mutex_scoped cache_lock(&_cache_mutex, write_lock);
@@ -1605,68 +1609,120 @@ bool Frame::GetSlicerSubImage(const StokesSlicer& stokes_slicer, casacore::SubIm
bool Frame::GetRegionData(const StokesRegion& stokes_region, std::vector& data, bool report_performance) {
// Get image data with a region applied
Timer t;
- casacore::SubImage sub_image;
- bool subimage_ok = GetRegionSubImage(stokes_region, sub_image);
+ std::vector region_mask;
- if (!subimage_ok) {
- return false;
- }
-
- casacore::IPosition subimage_shape = sub_image.shape();
- if (subimage_shape.empty()) {
- return false;
+ if (IsCurrentZStokes(stokes_region.stokes_source)) {
+ try {
+ // Slice cached image data using LCRegion bounding box
+ casacore::Slicer bounding_box = stokes_region.image_region.asLCRegion().boundingBox();
+ StokesSlicer stokes_slicer(stokes_region.stokes_source, bounding_box);
+ data.resize(bounding_box.length().product());
+
+ if (GetSlicerData(stokes_slicer, data.data())) {
+ // Next get the LCRegion as a mask (LCRegion is a Lattice)
+ casacore::Array tmpmask = stokes_region.image_region.asLCRegion().get();
+ region_mask = tmpmask.tovector();
+ } else {
+ data.clear();
+ }
+ } catch (const casacore::AipsError& err) {
+ // ImageRegion underlying region was not LCRegion
+ data.clear();
+ }
}
- try {
- casacore::IPosition start(subimage_shape.size(), 0);
- casacore::IPosition count(subimage_shape);
- casacore::Slicer slicer(start, count); // entire subimage
- bool is_computed_stokes(!stokes_region.stokes_source.IsOriginalImage());
+ if (data.empty()) {
+ // Apply region to image to get SubImage data
+ casacore::SubImage sub_image;
+ bool subimage_ok = GetRegionSubImage(stokes_region, sub_image);
- // Get image data
- std::unique_lock ulock(_image_mutex);
- if (_loader->IsGenerated() || is_computed_stokes) { // For the image in memory
- casacore::Array tmp;
- sub_image.doGetSlice(tmp, slicer);
- data = tmp.tovector();
- } else {
- data.resize(subimage_shape.product()); // must size correctly before sharing
- casacore::Array tmp(subimage_shape, data.data(), casacore::StorageInitPolicy::SHARE);
- sub_image.doGetSlice(tmp, slicer);
+ if (!subimage_ok) {
+ return false;
}
- // Get mask that defines region in subimage bounding box
- casacore::Array tmpmask;
- sub_image.doGetMaskSlice(tmpmask, slicer);
- ulock.unlock();
+ casacore::IPosition subimage_shape = sub_image.shape();
+ if (subimage_shape.empty()) {
+ return false;
+ }
- // Apply mask to data
- std::vector datamask = tmpmask.tovector();
- for (size_t i = 0; i < data.size(); ++i) {
- if (!datamask[i]) {
- data[i] = NAN;
+ try {
+ casacore::IPosition start(subimage_shape.size(), 0);
+ casacore::IPosition count(subimage_shape);
+ casacore::Slicer slicer(start, count); // entire subimage
+ bool is_computed_stokes(!stokes_region.stokes_source.IsOriginalImage());
+
+ // Get image data and mask, with image mutex locked
+ std::unique_lock ulock(_image_mutex);
+ casacore::Array tmpdata;
+ if (_loader->IsGenerated() || is_computed_stokes) { // For the image in memory
+ sub_image.doGetSlice(tmpdata, slicer);
+ data = tmpdata.tovector();
+ } else {
+ data.resize(subimage_shape.product()); // must size correctly before sharing
+ tmpdata = casacore::Array(subimage_shape, data.data(), casacore::StorageInitPolicy::SHARE);
+ sub_image.doGetSlice(tmpdata, slicer);
}
+
+ // Get mask that defines region in subimage bounding box
+ casacore::Array tmpmask;
+ sub_image.doGetMaskSlice(tmpmask, slicer);
+ ulock.unlock();
+ region_mask = tmpmask.tovector();
+ } catch (const casacore::AipsError& err) {
+ data.clear();
+ return false;
}
+ }
- if (report_performance) {
- spdlog::performance("Get region subimage data in {:.3f} ms", t.Elapsed().ms());
+ // Apply mask to data
+ for (size_t i = 0; i < data.size(); ++i) {
+ if (!region_mask[i]) {
+ data[i] = NAN;
}
+ }
- return true;
- } catch (casacore::AipsError& err) {
- data.clear();
+ if (report_performance) {
+ spdlog::performance("Get region subimage data in {:.3f} ms", t.Elapsed().ms());
}
- return false;
+ return true;
}
bool Frame::GetSlicerData(const StokesSlicer& stokes_slicer, float* data) {
- // Get image data with a slicer applied
+ // Get image data with a slicer applied; data must be correctly resized
+ bool data_ok(false);
casacore::Array tmp(stokes_slicer.slicer.length(), data, casacore::StorageInitPolicy::SHARE);
- std::unique_lock ulock(_image_mutex);
- bool data_ok = _loader->GetSlice(tmp, stokes_slicer);
- _loader->CloseImageIfUpdated();
- ulock.unlock();
+
+ if (_image_cache_valid && IsCurrentZStokes(stokes_slicer.stokes_source)) {
+ // Slice image cache
+ auto cache_shape = ImageShape();
+ auto slicer_start = stokes_slicer.slicer.start();
+ auto slicer_end = stokes_slicer.slicer.end();
+
+ // Adjust cache shape and slicer for single channel and stokes
+ if (_spectral_axis >= 0) {
+ cache_shape(_spectral_axis) = 1;
+ slicer_start(_spectral_axis) = 0;
+ slicer_end(_spectral_axis) = 0;
+ }
+ if (_stokes_axis >= 0) {
+ cache_shape(_stokes_axis) = 1;
+ slicer_start(_stokes_axis) = 0;
+ slicer_end(_stokes_axis) = 0;
+ }
+ casacore::Slicer cache_slicer(slicer_start, slicer_end, casacore::Slicer::endIsLast);
+
+ queuing_rw_mutex_scoped cache_lock(&_cache_mutex, false); // read lock
+ casacore::Array image_cache_as_array(cache_shape, _image_cache.get(), casacore::StorageInitPolicy::SHARE);
+ tmp = image_cache_as_array(cache_slicer);
+ data_ok = true;
+ } else {
+ // Use loader to slice image
+ std::unique_lock ulock(_image_mutex);
+ data_ok = _loader->GetSlice(tmp, stokes_slicer);
+ _loader->CloseImageIfUpdated();
+ ulock.unlock();
+ }
return data_ok;
}
@@ -1827,7 +1883,7 @@ bool Frame::FitImage(const CARTA::FittingRequest& fitting_request, CARTA::Fittin
}
casa::SPIIF image(_loader->GetStokesImage(output_stokes_region.stokes_source));
success = _image_fitter->GetGeneratedImages(
- image, output_stokes_region.image_region, file_id, GetFileName(), model_image, residual_image, fitting_response);
+ image, output_stokes_region.image_region, GetFileName(), model_image, residual_image, fitting_response);
}
}
diff --git a/src/Frame/Frame.h b/src/Frame/Frame.h
index 023373786..7d56cce54 100644
--- a/src/Frame/Frame.h
+++ b/src/Frame/Frame.h
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//# Frame.h: represents an open image file. Handles slicing data and region calculations
//# (profiles, histograms, stats)
-#ifndef CARTA_BACKEND__FRAME_H_
-#define CARTA_BACKEND__FRAME_H_
+#ifndef CARTA_SRC_FRAME_FRAME_H_
+#define CARTA_SRC_FRAME_FRAME_H_
#include
#include
@@ -105,6 +105,7 @@ class Frame {
size_t NumStokes(); // if no stokes axis, nstokes=1
int CurrentZ();
int CurrentStokes();
+ bool IsCurrentZStokes(const StokesSource& stokes_source);
int SpectralAxis();
int StokesAxis();
bool GetBeams(std::vector& beams);
@@ -296,7 +297,6 @@ class Frame {
ContourSettings _contour_settings;
// Image data cache and mutex
- // std::vector _image_cache; // image data for current z, stokes
long long int _image_cache_size;
std::unique_ptr _image_cache;
bool _image_cache_valid; // cached image data is valid for current z and stokes
@@ -337,4 +337,4 @@ class Frame {
} // namespace carta
-#endif // CARTA_BACKEND__FRAME_H_
+#endif // CARTA_SRC_FRAME_FRAME_H_
diff --git a/src/HttpServer/HttpServer.cc b/src/HttpServer/HttpServer.cc
index 282a7fe07..44e40980a 100644
--- a/src/HttpServer/HttpServer.cc
+++ b/src/HttpServer/HttpServer.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -24,7 +24,13 @@ using json = nlohmann::json;
namespace carta {
-const std::string success_string = json({{"success", true}}).dump();
+const std::string SUCCESS_STRING = json({{"success", true}}).dump();
+const std::string LAYOUT = "layout";
+const std::string SNIPPET = "snippet";
+const std::string WORKSPACE = "workspace";
+
+const std::unordered_map SCHEMA_URLS = {
+ {LAYOUT, CARTA_LAYOUT_SCHEMA_URL}, {SNIPPET, CARTA_SNIPPET_SCHEMA_URL}, {WORKSPACE, CARTA_WORKSPACE_SCHEMA_URL}};
uint32_t HttpServer::_scripting_request_id = 0;
@@ -67,23 +73,16 @@ void HttpServer::RegisterRoutes() {
app.put(fmt::format("{}/api/database/preferences", _url_prefix), [&](auto res, auto req) { HandleSetPreferences(res, req); });
app.del(fmt::format("{}/api/database/preferences", _url_prefix), [&](auto res, auto req) { HandleClearPreferences(res, req); });
- app.get(fmt::format("{}/api/database/list/layouts", _url_prefix), [&](auto res, auto req) { HandleGetObjectList("layout", res, req); });
- app.get(fmt::format("{}/api/database/layouts", _url_prefix), [&](auto res, auto req) { HandleGetObjects("layout", res, req); });
- app.get(fmt::format("{}/api/database/layout/:name", _url_prefix), [&](auto res, auto req) { HandleGetObject("layout", res, req); });
- app.put(fmt::format("{}/api/database/layout", _url_prefix), [&](auto res, auto req) { HandleSetObject("layout", res, req); });
- app.del(fmt::format("{}/api/database/layout", _url_prefix), [&](auto res, auto req) { HandleClearObject("layout", res, req); });
-
- app.get(fmt::format("{}/api/database/list/snippets", _url_prefix), [&](auto res, auto req) { HandleGetObjectList("snippet", res, req); });
- app.get(fmt::format("{}/api/database/snippets", _url_prefix), [&](auto res, auto req) { HandleGetObjects("snippet", res, req); });
- app.get(fmt::format("{}/api/database/snippet/:name", _url_prefix), [&](auto res, auto req) { HandleGetObject("snippet", res, req); });
- app.put(fmt::format("{}/api/database/snippet", _url_prefix), [&](auto res, auto req) { HandleSetObject("snippet", res, req); });
- app.del(fmt::format("{}/api/database/snippet", _url_prefix), [&](auto res, auto req) { HandleClearObject("snippet", res, req); });
-
- app.get(fmt::format("{}/api/database/list/workspaces", _url_prefix), [&](auto res, auto req) { HandleGetObjectList("workspace", res, req); });
- app.get(fmt::format("{}/api/database/workspaces", _url_prefix), [&](auto res, auto req) { HandleGetObjects("workspace", res, req); });
- app.get(fmt::format("{}/api/database/workspace/:name", _url_prefix), [&](auto res, auto req) { HandleGetObject("workspace", res, req); });
- app.put(fmt::format("{}/api/database/workspace", _url_prefix), [&](auto res, auto req) { HandleSetObject("workspace", res, req); });
- app.del(fmt::format("{}/api/database/workspace", _url_prefix), [&](auto res, auto req) { HandleClearObject("workspace", res, req); });
+ for (const auto& elem : SCHEMA_URLS) {
+ const auto& object_type = elem.first;
+ app.get(fmt::format("{}/api/database/list/{}s", _url_prefix, object_type),
+ [&](auto res, auto req) { HandleGetObjectList(object_type, res, req); });
+ app.get(fmt::format("{}/api/database/{}s", _url_prefix, object_type), [&](auto res, auto req) { HandleGetObjects(object_type, res, req); });
+ app.get(
+ fmt::format("{}/api/database/{}/:name", _url_prefix, object_type), [&](auto res, auto req) { HandleGetObject(object_type, res, req); });
+ app.put(fmt::format("{}/api/database/{}", _url_prefix, object_type), [&](auto res, auto req) { HandleSetObject(object_type, res, req); });
+ app.del(fmt::format("{}/api/database/{}", _url_prefix, object_type), [&](auto res, auto req) { HandleClearObject(object_type, res, req); });
+ }
} else {
app.get(fmt::format("{}/api/database/*", _url_prefix), [&](auto res, auto req) { NotImplemented(res, req); });
app.put(fmt::format("{}/api/database/*", _url_prefix), [&](auto res, auto req) { NotImplemented(res, req); });
@@ -347,7 +346,7 @@ void HttpServer::HandleSetPreferences(Res* res, Req* req) {
res->writeHeader("Content-Type", "application/json");
AddNoCacheHeaders(res);
if (status == HTTP_200) {
- res->end(success_string);
+ res->end(SUCCESS_STRING);
} else {
res->end();
}
@@ -402,7 +401,7 @@ void HttpServer::HandleClearPreferences(Res* res, Req* req) {
AddNoCacheHeaders(res);
res->writeHeader("Content-Type", "application/json");
if (status == HTTP_200) {
- res->end(success_string);
+ res->end(SUCCESS_STRING);
} else {
res->end();
}
@@ -479,7 +478,7 @@ void HttpServer::HandleSetObject(const std::string& object_type, Res* res, Req*
AddNoCacheHeaders(res);
res->writeHeader("Content-Type", "application/json");
if (status == HTTP_200) {
- res->end(success_string);
+ res->end(SUCCESS_STRING);
} else {
res->end();
}
@@ -498,7 +497,7 @@ void HttpServer::HandleClearObject(const std::string& object_type, Res* res, Req
AddNoCacheHeaders(res);
res->writeHeader("Content-Type", "application/json");
if (status == HTTP_200) {
- res->end(success_string);
+ res->end(SUCCESS_STRING);
} else {
res->end();
}
@@ -595,12 +594,11 @@ bool HttpServer::WriteObjectFile(const std::string& object_type, const std::stri
fs::create_directories(object_path.parent_path());
std::ofstream file(object_path.string());
// Ensure correct schema value is written
- if (object_type == "layout") {
- obj["$schema"] = CARTA_LAYOUT_SCHEMA_URL;
- } else if (object_type == "snippet") {
- obj["$schema"] = CARTA_SNIPPET_SCHEMA_URL;
- } else if (object_type == "workspace") {
- obj["$schema"] = CARTA_WORKSPACE_SCHEMA_URL;
+ if (SCHEMA_URLS.count(object_type)) {
+ obj["$schema"] = SCHEMA_URLS.at(object_type);
+ } else {
+ spdlog::error("Unknown object types: {}.", object_type);
+ return false;
}
auto json_string = obj.dump(4);
diff --git a/src/HttpServer/HttpServer.h b/src/HttpServer/HttpServer.h
index 20c9b7a6f..f40af7d32 100644
--- a/src/HttpServer/HttpServer.h
+++ b/src/HttpServer/HttpServer.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_SRC_HTTPSERVER_HTTPSERVER_H_
-#define CARTA_BACKEND_SRC_HTTPSERVER_HTTPSERVER_H_
+#ifndef CARTA_SRC_HTTPSERVER_HTTPSERVER_H_
+#define CARTA_SRC_HTTPSERVER_HTTPSERVER_H_
#include
#include
@@ -102,4 +102,4 @@ class HttpServer {
};
} // namespace carta
-#endif // CARTA_BACKEND_SRC_HTTPSERVER_HTTPSERVER_H_
+#endif // CARTA_SRC_HTTPSERVER_HTTPSERVER_H_
diff --git a/src/HttpServer/MimeTypes.h b/src/HttpServer/MimeTypes.h
index 794eab6f5..5837c85de 100644
--- a/src/HttpServer/MimeTypes.h
+++ b/src/HttpServer/MimeTypes.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_SRC_HTTPSERVER_MIMETYPES_H_
-#define CARTA_BACKEND_SRC_HTTPSERVER_MIMETYPES_H_
+#ifndef CARTA_SRC_HTTPSERVER_MIMETYPES_H_
+#define CARTA_SRC_HTTPSERVER_MIMETYPES_H_
#include
#include
@@ -16,4 +16,4 @@ const static std::unordered_map MimeTypes = {{".css",
{".svg", "image/svg+xml"}, {".woff", "font/woff"}, {".woff2", "font/woff2"}, {".wasm", "application/wasm"}};
} // namespace carta
-#endif // CARTA_BACKEND_SRC_HTTPSERVER_MIMETYPES_H_
+#endif // CARTA_SRC_HTTPSERVER_MIMETYPES_H_
diff --git a/src/ImageData/CartaFitsImage.cc b/src/ImageData/CartaFitsImage.cc
index 13f29a91f..98e16a8f7 100644
--- a/src/ImageData/CartaFitsImage.cc
+++ b/src/ImageData/CartaFitsImage.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -475,7 +475,8 @@ void CartaFitsImage::SetFitsHeaderStrings(int nheaders, const std::string& heade
}
// For setting up image
- _image_header_strings = no_history_strings;
+ casacore::Vector const no_history_strings_v(no_history_strings);
+ _image_header_strings = no_history_strings_v;
}
casacore::Vector CartaFitsImage::FitsHeaderStrings() {
diff --git a/src/ImageData/CartaFitsImage.h b/src/ImageData/CartaFitsImage.h
index 4a6c01fc4..845c606ff 100644
--- a/src/ImageData/CartaFitsImage.h
+++ b/src/ImageData/CartaFitsImage.h
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//# CartaFitsImage.h : FITS Image class derived from casacore::ImageInterface for images not supported by casacore,
//# including compressed and Int64
-#ifndef CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_H_
-#define CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_H_
+#ifndef CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_H_
+#define CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_H_
#include
#include
@@ -125,4 +125,4 @@ class CartaFitsImage : public casacore::ImageInterface {
#include "CartaFitsImage.tcc"
-#endif // CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_H_
+#endif // CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_H_
diff --git a/src/ImageData/CartaFitsImage.tcc b/src/ImageData/CartaFitsImage.tcc
index e40b97283..72c491b64 100644
--- a/src/ImageData/CartaFitsImage.tcc
+++ b/src/ImageData/CartaFitsImage.tcc
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_TCC_
-#define CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_TCC_
+#ifndef CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_TCC_
+#define CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_TCC_
#include "CartaFitsImage.h"
@@ -168,4 +168,4 @@ bool CartaFitsImage::GetNanPixelMask(casacore::ArrayLattice& mask) {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_CARTAFITSIMAGE_TCC_
+#endif // CARTA_SRC_IMAGEDATA_CARTAFITSIMAGE_TCC_
diff --git a/src/ImageData/CartaHdf5Image.cc b/src/ImageData/CartaHdf5Image.cc
index 77542ef81..d9ef37db3 100644
--- a/src/ImageData/CartaHdf5Image.cc
+++ b/src/ImageData/CartaHdf5Image.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/CartaHdf5Image.h b/src/ImageData/CartaHdf5Image.h
index c10405796..419ca1535 100644
--- a/src/ImageData/CartaHdf5Image.h
+++ b/src/ImageData/CartaHdf5Image.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# CartaHdf5Image.h : HDF5 Image class derived from casacore::ImageInterface
-#ifndef CARTA_BACKEND_IMAGEDATA_CARTAHDF5IMAGE_H_
-#define CARTA_BACKEND_IMAGEDATA_CARTAHDF5IMAGE_H_
+#ifndef CARTA_SRC_IMAGEDATA_CARTAHDF5IMAGE_H_
+#define CARTA_SRC_IMAGEDATA_CARTAHDF5IMAGE_H_
#include
#include
@@ -85,4 +85,4 @@ class CartaHdf5Image : public casacore::ImageInterface {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_CARTAHDF5IMAGE_H_
+#endif // CARTA_SRC_IMAGEDATA_CARTAHDF5IMAGE_H_
diff --git a/src/ImageData/CartaMiriadImage.cc b/src/ImageData/CartaMiriadImage.cc
index be6692d3b..99074fede 100644
--- a/src/ImageData/CartaMiriadImage.cc
+++ b/src/ImageData/CartaMiriadImage.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/CartaMiriadImage.h b/src/ImageData/CartaMiriadImage.h
index e503eee2b..73ba0c78d 100644
--- a/src/ImageData/CartaMiriadImage.h
+++ b/src/ImageData/CartaMiriadImage.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# CartaMiriadImage.h : MIRIAD Image class to support masks
-#ifndef CARTA_BACKEND_IMAGEDATA_CARTAMIRIADIMAGE_H_
-#define CARTA_BACKEND_IMAGEDATA_CARTAMIRIADIMAGE_H_
+#ifndef CARTA_SRC_IMAGEDATA_CARTAMIRIADIMAGE_H_
+#define CARTA_SRC_IMAGEDATA_CARTAMIRIADIMAGE_H_
#include
#include
@@ -62,4 +62,4 @@ class CartaMiriadImage : public casacore::MIRIADImage {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_CARTAMIRIADIMAGE_H_
+#endif // CARTA_SRC_IMAGEDATA_CARTAMIRIADIMAGE_H_
diff --git a/src/ImageData/CasaLoader.h b/src/ImageData/CasaLoader.h
index 67e2ce86e..c1f95db73 100644
--- a/src/ImageData/CasaLoader.h
+++ b/src/ImageData/CasaLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_CASALOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_CASALOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_CASALOADER_H_
+#define CARTA_SRC_IMAGEDATA_CASALOADER_H_
#include
#include
@@ -129,4 +129,4 @@ casacore::TempImage* CasaLoader::ConvertImageToFloat(casacore::LatticeBas
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_CASALOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_CASALOADER_H_
diff --git a/src/ImageData/CompListLoader.h b/src/ImageData/CompListLoader.h
index 9dd4dae5c..1691837bb 100644
--- a/src/ImageData/CompListLoader.h
+++ b/src/ImageData/CompListLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_COMPLISTLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_COMPLISTLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_COMPLISTLOADER_H_
+#define CARTA_SRC_IMAGEDATA_COMPLISTLOADER_H_
#include
#include
@@ -43,4 +43,4 @@ void CompListLoader::AllocateImage(const std::string& /*hdu*/) {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_COMPLISTLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_COMPLISTLOADER_H_
diff --git a/src/ImageData/CompressedFits.cc b/src/ImageData/CompressedFits.cc
index 63cd40d74..7e9c9dda5 100644
--- a/src/ImageData/CompressedFits.cc
+++ b/src/ImageData/CompressedFits.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -414,6 +414,10 @@ void CompressedFits::AddHeaderEntry(
} catch (std::invalid_argument) {
// Set string value only
entry->set_entry_type(CARTA::EntryType::STRING);
+ } catch (std::out_of_range) {
+ long lvalue = std::stol(value);
+ entry->set_numeric_value(lvalue);
+ entry->set_entry_type(CARTA::EntryType::INT);
}
}
}
diff --git a/src/ImageData/CompressedFits.h b/src/ImageData/CompressedFits.h
index 7c3103519..4ecd99d4e 100644
--- a/src/ImageData/CompressedFits.h
+++ b/src/ImageData/CompressedFits.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_COMPRESSEDFITS_H_
-#define CARTA_BACKEND_IMAGEDATA_COMPRESSEDFITS_H_
+#ifndef CARTA_SRC_IMAGEDATA_COMPRESSEDFITS_H_
+#define CARTA_SRC_IMAGEDATA_COMPRESSEDFITS_H_
#include
#include
@@ -159,4 +159,4 @@ class CompressedFits {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_COMPRESSEDFITS_H_
+#endif // CARTA_SRC_IMAGEDATA_COMPRESSEDFITS_H_
diff --git a/src/ImageData/ConcatLoader.h b/src/ImageData/ConcatLoader.h
index 5fe6d10b0..88185f7b9 100644
--- a/src/ImageData/ConcatLoader.h
+++ b/src/ImageData/ConcatLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_CONCATLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_CONCATLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_CONCATLOADER_H_
+#define CARTA_SRC_IMAGEDATA_CONCATLOADER_H_
#include
#include
@@ -44,4 +44,4 @@ void ConcatLoader::AllocateImage(const std::string& /*hdu*/) {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_CONCATLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_CONCATLOADER_H_
diff --git a/src/ImageData/ExprLoader.h b/src/ImageData/ExprLoader.h
index 7a7cd878b..a908ac09a 100644
--- a/src/ImageData/ExprLoader.h
+++ b/src/ImageData/ExprLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_EXPRLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_EXPRLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_EXPRLOADER_H_
+#define CARTA_SRC_IMAGEDATA_EXPRLOADER_H_
#include
#include
@@ -93,4 +93,4 @@ bool ExprLoader::SaveFile(const CARTA::FileType type, const std::string& output_
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_EXPRLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_EXPRLOADER_H_
diff --git a/src/ImageData/FileInfo.cc b/src/ImageData/FileInfo.cc
index ff49cd3e0..9ad3c3884 100644
--- a/src/ImageData/FileInfo.cc
+++ b/src/ImageData/FileInfo.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/FileInfo.h b/src/ImageData/FileInfo.h
index c058a5fac..e57c4a7b6 100644
--- a/src/ImageData/FileInfo.h
+++ b/src/ImageData/FileInfo.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_FILEINFO_H
-#define CARTA_BACKEND_FILEINFO_H
+#ifndef CARTA_SRC_IMAGEDATA_FILEINFO_H_
+#define CARTA_SRC_IMAGEDATA_FILEINFO_H_
#include
#include
@@ -138,4 +138,4 @@ static bool ConvertFitsStokesValue(const int& in_stokes_value, int& out_stokes_v
} // namespace FileInfo
} // namespace carta
-#endif // CARTA_BACKEND_FILEINFO_H
+#endif // CARTA_SRC_IMAGEDATA_FILEINFO_H_
diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc
index 1fe67cf50..3eacec890 100644
--- a/src/ImageData/FileLoader.cc
+++ b/src/ImageData/FileLoader.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h
index 17e037bea..5765a5314 100644
--- a/src/ImageData/FileLoader.h
+++ b/src/ImageData/FileLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_FILELOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_FILELOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_FILELOADER_H_
+#define CARTA_SRC_IMAGEDATA_FILELOADER_H_
#include
#include
@@ -207,4 +207,4 @@ class FileLoader {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_FILELOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_FILELOADER_H_
diff --git a/src/ImageData/FitsLoader.cc b/src/ImageData/FitsLoader.cc
index d8dedb44e..1848bd759 100644
--- a/src/ImageData/FitsLoader.cc
+++ b/src/ImageData/FitsLoader.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -62,14 +62,14 @@ void FitsLoader::AllocateImage(const std::string& hdu) {
}
}
- // Default is casacore::FITSImage; if fails, try CartaFitsImage
- bool use_casacore_fits(true);
- auto num_headers = GetNumHeaders(_filename, hdu_num);
-
+ std::string error;
+ auto num_headers = GetNumImageHeaders(_filename, hdu_num, error);
if (num_headers == 0) {
- throw(casacore::AipsError("Error reading FITS file."));
+ throw(casacore::AipsError(error));
}
+ // Default is casacore::FITSImage; if fails, try CartaFitsImage
+ bool use_casacore_fits(true);
if (num_headers > 2000) {
// casacore::FITSImage parses HISTORY
use_casacore_fits = false;
@@ -135,8 +135,8 @@ void FitsLoader::AllocateImage(const std::string& hdu) {
}
}
-int FitsLoader::GetNumHeaders(const std::string& filename, int hdu) {
- // Return number of FITS headers, 0 if error.
+int FitsLoader::GetNumImageHeaders(const std::string& filename, int hdu, std::string& error) {
+ // Return number of FITS headers if image hdu, 0 if error.
int num_headers(0);
// Open file read-only
@@ -144,13 +144,29 @@ int FitsLoader::GetNumHeaders(const std::string& filename, int hdu) {
int status(0);
fits_open_file(&fptr, filename.c_str(), 0, &status);
if (status) {
+ error = "Error reading FITS file.";
return num_headers;
}
- // Advance to hdu (FITS hdu is 1-based)
- int* hdutype(nullptr);
- fits_movabs_hdu(fptr, hdu + 1, hdutype, &status);
+ // Advance to hdu (FITS hdu is 1-based) and check if image
+ int hdutype(-1);
+ fits_movabs_hdu(fptr, hdu + 1, &hdutype, &status);
if (status) {
+ error = "Cannot advance to requested HDU.";
+ return num_headers;
+ }
+ if (hdutype != IMAGE_HDU) {
+ error = "HDU is not an image.";
+ return num_headers;
+ }
+
+ // Check if image exists in HDU
+ std::string key("NAXIS");
+ char* comment(nullptr); // unused
+ int naxis(0);
+ fits_read_key(fptr, TINT, key.c_str(), &naxis, comment, &status);
+ if (naxis == 0) {
+ error = "HDU image is empty.";
return num_headers;
}
diff --git a/src/ImageData/FitsLoader.h b/src/ImageData/FitsLoader.h
index 13ae2cc6f..a2fce9796 100644
--- a/src/ImageData/FitsLoader.h
+++ b/src/ImageData/FitsLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_FITSLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_FITSLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_FITSLOADER_H_
+#define CARTA_SRC_IMAGEDATA_FITSLOADER_H_
#include "FileLoader.h"
@@ -21,7 +21,7 @@ class FitsLoader : public FileLoader {
casacore::uInt _hdu_num;
void AllocateImage(const std::string& hdu) override;
- int GetNumHeaders(const std::string& filename, int hdu);
+ int GetNumImageHeaders(const std::string& filename, int hdu, std::string& error);
// Image beam headers/table
bool Is64BitBeamsTable(const std::string& filename);
@@ -32,4 +32,4 @@ class FitsLoader : public FileLoader {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_FITSLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_FITSLOADER_H_
diff --git a/src/ImageData/Hdf5Attributes.cc b/src/ImageData/Hdf5Attributes.cc
index 4b13340b5..5d5d63c0a 100644
--- a/src/ImageData/Hdf5Attributes.cc
+++ b/src/ImageData/Hdf5Attributes.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/Hdf5Attributes.h b/src/ImageData/Hdf5Attributes.h
index 341e7efc8..a203f192e 100644
--- a/src/ImageData/Hdf5Attributes.h
+++ b/src/ImageData/Hdf5Attributes.h
@@ -1,12 +1,12 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# Hdf5Attributes.h: get HDF5 header attributes in casacore::Record
-#ifndef CARTA_BACKEND_IMAGEDATA_HDF5ATTRIBUTES_H_
-#define CARTA_BACKEND_IMAGEDATA_HDF5ATTRIBUTES_H_
+#ifndef CARTA_SRC_IMAGEDATA_HDF5ATTRIBUTES_H_
+#define CARTA_SRC_IMAGEDATA_HDF5ATTRIBUTES_H_
#pragma once
@@ -27,4 +27,4 @@ class Hdf5Attributes {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_HDF5ATTRIBUTES_H_
+#endif // CARTA_SRC_IMAGEDATA_HDF5ATTRIBUTES_H_
diff --git a/src/ImageData/Hdf5Loader.cc b/src/ImageData/Hdf5Loader.cc
index e5b853a8e..ca9f0811a 100644
--- a/src/ImageData/Hdf5Loader.cc
+++ b/src/ImageData/Hdf5Loader.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/Hdf5Loader.h b/src/ImageData/Hdf5Loader.h
index 08360c8a2..14f9acebf 100644
--- a/src/ImageData/Hdf5Loader.h
+++ b/src/ImageData/Hdf5Loader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_HDF5LOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_HDF5LOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_HDF5LOADER_H_
+#define CARTA_SRC_IMAGEDATA_HDF5LOADER_H_
#include
#include
@@ -72,4 +72,4 @@ class Hdf5Loader : public FileLoader {
#include "Hdf5Loader.tcc"
-#endif // CARTA_BACKEND_IMAGEDATA_HDF5LOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_HDF5LOADER_H_
diff --git a/src/ImageData/Hdf5Loader.tcc b/src/ImageData/Hdf5Loader.tcc
index 1b9db3664..c2cb19e4b 100644
--- a/src/ImageData/Hdf5Loader.tcc
+++ b/src/ImageData/Hdf5Loader.tcc
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_HDF5LOADER_TCC_
-#define CARTA_BACKEND_IMAGEDATA_HDF5LOADER_TCC_
+#ifndef CARTA_SRC_IMAGEDATA_HDF5LOADER_TCC_
+#define CARTA_SRC_IMAGEDATA_HDF5LOADER_TCC_
#include "Hdf5Loader.h"
@@ -66,4 +66,4 @@ std::unique_ptr Hdf5Loader::GetStatsDataTyped(FileInfo::Dat
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_HDF5LOADER_TCC_
+#endif // CARTA_SRC_IMAGEDATA_HDF5LOADER_TCC_
diff --git a/src/ImageData/ImagePtrLoader.h b/src/ImageData/ImagePtrLoader.h
index 0e8351cfb..85fa9424c 100644
--- a/src/ImageData/ImagePtrLoader.h
+++ b/src/ImageData/ImagePtrLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_IMAGEPTRLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_IMAGEPTRLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_IMAGEPTRLOADER_H_
+#define CARTA_SRC_IMAGEDATA_IMAGEPTRLOADER_H_
#include "FileLoader.h"
@@ -34,4 +34,4 @@ void ImagePtrLoader::AllocateImage(const std::string& /*hdu*/) {}
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_IMAGEPTRLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_IMAGEPTRLOADER_H_
diff --git a/src/ImageData/MiriadLoader.h b/src/ImageData/MiriadLoader.h
index f0dd8a704..810ed23f5 100644
--- a/src/ImageData/MiriadLoader.h
+++ b/src/ImageData/MiriadLoader.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEDATA_MIRIADLOADER_H_
-#define CARTA_BACKEND_IMAGEDATA_MIRIADLOADER_H_
+#ifndef CARTA_SRC_IMAGEDATA_MIRIADLOADER_H_
+#define CARTA_SRC_IMAGEDATA_MIRIADLOADER_H_
#include
@@ -71,4 +71,4 @@ void MiriadLoader::AllocateImage(const std::string& /*hdu*/) {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEDATA_MIRIADLOADER_H_
+#endif // CARTA_SRC_IMAGEDATA_MIRIADLOADER_H_
diff --git a/src/ImageData/PolarizationCalculator.cc b/src/ImageData/PolarizationCalculator.cc
index baad86c23..71e901504 100644
--- a/src/ImageData/PolarizationCalculator.cc
+++ b/src/ImageData/PolarizationCalculator.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageData/PolarizationCalculator.h b/src/ImageData/PolarizationCalculator.h
index 239357e7e..c47fce60d 100644
--- a/src/ImageData/PolarizationCalculator.h
+++ b/src/ImageData/PolarizationCalculator.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__IMAGEDATA_POLARIZATIONCALCULATOR_H_
-#define CARTA_BACKEND__IMAGEDATA_POLARIZATIONCALCULATOR_H_
+#ifndef CARTA_SRC_IMAGEDATA_POLARIZATIONCALCULATOR_H_
+#define CARTA_SRC_IMAGEDATA_POLARIZATIONCALCULATOR_H_
#include
#include
@@ -50,4 +50,4 @@ class PolarizationCalculator {
} // namespace carta
-#endif // CARTA_BACKEND__IMAGEDATA_POLARIZATIONCALCULATOR_H_
+#endif // CARTA_SRC_IMAGEDATA_POLARIZATIONCALCULATOR_H_
diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc
index 5a0c3b280..845275999 100644
--- a/src/ImageData/StokesFilesConnector.cc
+++ b/src/ImageData/StokesFilesConnector.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -201,28 +201,28 @@ bool StokesFilesConnector::OpenStokesFiles(const CARTA::ConcatStokesFiles& messa
for (int i = 0; i < message.stokes_files_size(); ++i) {
auto stokes_file = message.stokes_files(i);
auto stokes_type = message.stokes_files(i).polarization_type();
- casacore::String hdu(stokes_file.hdu());
- casacore::String full_name(GetResolvedFilename(_top_level_folder, stokes_file.directory(), stokes_file.file()));
if (_loaders.count(stokes_type)) {
err = "Duplicate Stokes type found!";
return false;
}
+ casacore::String full_name(GetResolvedFilename(_top_level_folder, stokes_file.directory(), stokes_file.file(), err));
+
// open an image file
- if (!full_name.empty()) {
- try {
- if (hdu.empty()) { // use first when required
- hdu = "0";
- }
- _loaders[stokes_type].reset(FileLoader::GetLoader(full_name));
- _loaders[stokes_type]->OpenFile(hdu);
- } catch (casacore::AipsError& ex) {
- err = fmt::format("Failed to open the file: {}", ex.getMesg());
- return false;
+ if (full_name.empty()) {
+ return false;
+ }
+
+ try {
+ casacore::String hdu(stokes_file.hdu());
+ if (hdu.empty()) { // use first when required
+ hdu = "0";
}
- } else {
- err = "File name is empty or does not exist!";
+ _loaders[stokes_type].reset(FileLoader::GetLoader(full_name));
+ _loaders[stokes_type]->OpenFile(hdu);
+ } catch (casacore::AipsError& ex) {
+ err = fmt::format("Failed to open the file: {}", ex.getMesg());
return false;
}
diff --git a/src/ImageData/StokesFilesConnector.h b/src/ImageData/StokesFilesConnector.h
index ebe695dd1..197960662 100644
--- a/src/ImageData/StokesFilesConnector.h
+++ b/src/ImageData/StokesFilesConnector.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND__IMAGEDATA_STOKESFILESCONNECTOR_H_
-#define CARTA_BACKEND__IMAGEDATA_STOKESFILESCONNECTOR_H_
+#ifndef CARTA_SRC_IMAGEDATA_STOKESFILESCONNECTOR_H_
+#define CARTA_SRC_IMAGEDATA_STOKESFILESCONNECTOR_H_
#include
#include
@@ -36,4 +36,4 @@ class StokesFilesConnector {
} // namespace carta
-#endif // CARTA_BACKEND__IMAGEDATA_STOKESFILESCONNECTOR_H_
+#endif // CARTA_SRC_IMAGEDATA_STOKESFILESCONNECTOR_H_
diff --git a/src/ImageFitter/ImageFitter.cc b/src/ImageFitter/ImageFitter.cc
index 6c8d46808..84e709871 100644
--- a/src/ImageFitter/ImageFitter.cc
+++ b/src/ImageFitter/ImageFitter.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -47,7 +47,7 @@ bool ImageFitter::FitImage(size_t width, size_t height, float* image, double bea
_create_residual_data = create_residual_image;
_progress_callback = progress_callback;
- CalculateNanNum();
+ CalculateNanNumAndStd();
SetInitialValues(initial_values, background_offset, fixed_params);
// avoid SolveSystem crashes with insufficient data points
@@ -113,26 +113,13 @@ bool ImageFitter::FitImage(size_t width, size_t height, float* image, double bea
return success;
}
-bool ImageFitter::GetGeneratedImages(casa::SPIIF image, const casacore::ImageRegion& image_region, int file_id, const std::string& filename,
+bool ImageFitter::GetGeneratedImages(casa::SPIIF image, const casacore::ImageRegion& image_region, const std::string& filename,
GeneratedImage& model_image, GeneratedImage& residual_image, CARTA::FittingResponse& fitting_response) {
- if (file_id < 0) {
- fitting_response.set_message("generating images from generated PV and model/residual images is not supported");
- return false;
- }
-
- // Todo: find another better way to assign the temp file Id
- bool is_moment = file_id > 999;
- int model_id = (file_id + 1) * (is_moment ? FITTING_WITH_MOMENT_ID_MULTIPLIER : FITTING_ID_MULTIPLIER) + 1;
- int residual_id = model_id + 1;
-
if (_create_model_data) {
- model_image = GeneratedImage(model_id, is_moment ? GetGeneratedMomentFilename(filename, "model") : GetFilename(filename, "model"),
- GetImageData(image, image_region, _model_data));
+ model_image = GeneratedImage(GetFilename(filename, "model"), GetImageData(image, image_region, _model_data));
}
if (_create_residual_data) {
- residual_image =
- GeneratedImage(residual_id, is_moment ? GetGeneratedMomentFilename(filename, "residual") : GetFilename(filename, "residual"),
- GetImageData(image, image_region, _residual_data));
+ residual_image = GeneratedImage(GetFilename(filename, "residual"), GetImageData(image, image_region, _residual_data));
}
return true;
}
@@ -141,13 +128,21 @@ void ImageFitter::StopFitting() {
_fit_data.stop_fitting = true;
}
-void ImageFitter::CalculateNanNum() {
+void ImageFitter::CalculateNanNumAndStd() {
+ std::vector data_notnan;
+ data_notnan.reserve(_fit_data.n);
+
_fit_data.n_notnan = _fit_data.n;
for (size_t i = 0; i < _fit_data.n; i++) {
if (isnan(_fit_data.data[i])) {
_fit_data.n_notnan--;
+ } else {
+ data_notnan.push_back(_fit_data.data[i]);
}
}
+
+ _image_std = GetMedianAbsDeviation(_fit_data.n_notnan, data_notnan.data());
+ spdlog::debug("MAD = {}", _image_std);
}
void ImageFitter::SetInitialValues(
@@ -221,9 +216,6 @@ int ImageFitter::SolveSystem(CARTA::FittingSolverType solver) {
gsl_vector* y = gsl_multifit_nlinear_position(work);
gsl_matrix* covar = gsl_matrix_alloc(p, p);
- gsl_multifit_nlinear_init(_fit_values, &_fdf, work); // work-around for filling in f
- _image_std = GetMedianAbsDeviation(_fdf.n, f->data);
-
gsl_vector* weights = gsl_vector_alloc(n);
gsl_vector_set_all(weights, 1 / _image_std / _image_std);
gsl_multifit_nlinear_winit(_fit_values, weights, &_fdf, work);
@@ -417,17 +409,20 @@ casa::SPIIF ImageFitter::GetImageData(casa::SPIIF image, const casacore::ImageRe
}
std::string ImageFitter::GetFilename(const std::string& filename, std::string suffix) {
- fs::path filepath(filename);
+ std::string moment_suffix;
+ fs::path filepath;
+ if (filename.rfind(".moment.") != std::string::npos) {
+ std::string input_filename = filename.substr(0, filename.rfind(".moment."));
+ filepath = fs::path(input_filename);
+ moment_suffix = filename.substr(filename.rfind(".moment."));
+ } else {
+ filepath = fs::path(filename);
+ }
+
fs::path output_filename = filepath.stem();
output_filename += "_" + suffix;
output_filename += filepath.extension();
- return output_filename.string();
-}
-
-std::string ImageFitter::GetGeneratedMomentFilename(const std::string& filename, std::string suffix) {
- std::string output_filename = filename.substr(0, filename.rfind(".moment."));
- std::string moment_suffix = filename.substr(filename.rfind(".moment."));
- return GetFilename(output_filename, suffix) + moment_suffix;
+ return output_filename.string() + moment_suffix;
}
int ImageFitter::FuncF(const gsl_vector* fit_values, void* fit_data, gsl_vector* f) {
diff --git a/src/ImageFitter/ImageFitter.h b/src/ImageFitter/ImageFitter.h
index 75ec90913..6a5684426 100644
--- a/src/ImageFitter/ImageFitter.h
+++ b/src/ImageFitter/ImageFitter.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEFITTER_IMAGEFITTER_H_
-#define CARTA_BACKEND_IMAGEFITTER_IMAGEFITTER_H_
+#ifndef CARTA_SRC_IMAGEFITTER_IMAGEFITTER_H_
+#define CARTA_SRC_IMAGEFITTER_IMAGEFITTER_H_
#include
#include
@@ -97,7 +97,7 @@ class ImageFitter {
* @param fitting_response The fitting response message
* @return Whether the images are successfully generated
*/
- bool GetGeneratedImages(std::shared_ptr> image, const casacore::ImageRegion& image_region, int file_id,
+ bool GetGeneratedImages(std::shared_ptr> image, const casacore::ImageRegion& image_region,
const std::string& filename, GeneratedImage& model_image, GeneratedImage& residual_image, CARTA::FittingResponse& fitting_response);
/** @brief Stop the ongoing fitting process. */
void StopFitting();
@@ -139,9 +139,9 @@ class ImageFitter {
GeneratorProgressCallback _progress_callback;
/**
- * @brief Calculate the number of NaN values in the image data.
+ * @brief Calculate the number of NaN values and standard deviation of the image data.
*/
- void CalculateNanNum();
+ void CalculateNanNumAndStd();
/**
* @brief Set initial fitting parameters for the fitting.
* @param initial_values Initial fitting parameters
@@ -242,4 +242,4 @@ class ImageFitter {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEFITTER_IMAGEFITTER_H_
+#endif // CARTA_SRC_IMAGEFITTER_IMAGEFITTER_H_
diff --git a/src/ImageGenerators/Image2DConvolver.h b/src/ImageGenerators/Image2DConvolver.h
index aba6089af..4a0adf56e 100644
--- a/src/ImageGenerators/Image2DConvolver.h
+++ b/src/ImageGenerators/Image2DConvolver.h
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//
// Re-write from the file: "carta-casacore/casa6/casa5/code/imageanalysis/ImageAnalysis/Image2DConvolver.h"
//
-#ifndef CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_H_
-#define CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_H_
+#define CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_H_
#include
#include
@@ -152,4 +152,4 @@ class Image2DConvolver : public casa::ImageTask {
#include "Image2DConvolver.tcc"
-#endif // CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_H_
diff --git a/src/ImageGenerators/Image2DConvolver.tcc b/src/ImageGenerators/Image2DConvolver.tcc
index c47342218..77ebefc2a 100644
--- a/src/ImageGenerators/Image2DConvolver.tcc
+++ b/src/ImageGenerators/Image2DConvolver.tcc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//
// Re-write from the file: "carta-casacore/casa6/casa5/code/imageanalysis/ImageAnalysis/Image2DConvolver.tcc"
//
-#ifndef CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_TCC_
-#define CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_TCC_
+#ifndef CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_TCC_
+#define CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_TCC_
#include "../Logger/Logger.h"
#include "Util/Casacore.h"
@@ -165,7 +165,8 @@ void Image2DConvolver::_convolve(SPIIT imageOut, const ImageInterface& ima
if (logFactors) {
pixelArea = cSys.directionCoordinate().getPixelArea().getValue("arcsec*arcsec");
if (!_targetres) {
- GaussianBeam kernelBeam(kernelParms);
+ casacore::Vector const kernelParmsV(kernelParms);
+ GaussianBeam kernelBeam(kernelParmsV);
factor1 = pixelArea / kernelBeam.getArea("arcsec*arcsec");
}
}
@@ -207,25 +208,27 @@ void Image2DConvolver::_doSingleBeam(ImageInfo& iiOut, Double& kernelVolume,
String& brightnessUnitOut, GaussianBeam& beamOut, SPIIT imageOut, const ImageInterface& imageIn,
const vector& originalParms, VectorKernel::KernelTypes kernelType, Bool logFactors, Double factor1, Double pixelArea) const {
GaussianBeam inputBeam = imageIn.imageInfo().restoringBeam();
+ casacore::Vector const kernelParmsV(kernelParms);
+ casacore::Vector const originalParmsV(originalParms);
if (_targetres) {
kernelParms = _getConvolvingBeamForTargetResolution(originalParms, inputBeam);
spdlog::debug("Convolving image that has a beam of {} with a Gaussian of {} to reach a target resolution of {}",
- FormatBeam(inputBeam), FormatBeam(GaussianBeam(kernelParms)), FormatBeam(GaussianBeam(originalParms)));
+ FormatBeam(inputBeam), FormatBeam(GaussianBeam(kernelParmsV)), FormatBeam(GaussianBeam(originalParmsV)));
kernelVolume = _makeKernel(kernel, kernelType, kernelParms, imageIn);
}
const CoordinateSystem& cSys = imageIn.coordinates();
auto scaleFactor = _dealWithRestoringBeam(
- brightnessUnitOut, beamOut, kernel, kernelVolume, kernelType, kernelParms, cSys, inputBeam, imageIn.units(), true);
+ brightnessUnitOut, beamOut, kernel, kernelVolume, kernelType, kernelParmsV, cSys, inputBeam, imageIn.units(), true);
string message;
message += "Scaling pixel values by ";
if (logFactors) {
if (_targetres) {
- GaussianBeam kernelBeam(kernelParms);
+ GaussianBeam kernelBeam(kernelParmsV);
factor1 = pixelArea / kernelBeam.getArea("arcsec*arcsec");
}
Double factor2 = beamOut.getArea("arcsec*arcsec") / inputBeam.getArea("arcsec*arcsec");
@@ -290,9 +293,10 @@ void Image2DConvolver::_doMultipleBeams(ImageInfo& iiOut, Double& kernelVolum
casacore::Int channel = -1;
casacore::Int polarization = -1;
+ casacore::Vector const kernelParmsV(kernelParms);
if (_targetres) {
iiOut.removeRestoringBeam();
- iiOut.setRestoringBeam(casacore::GaussianBeam(kernelParms));
+ iiOut.setRestoringBeam(casacore::GaussianBeam(kernelParmsV));
}
casacore::uInt count = (nChan > 0 && nPol > 0) ? nChan * nPol : nChan > 0 ? nChan : nPol;
@@ -347,14 +351,15 @@ void Image2DConvolver::_doMultipleBeams(ImageInfo& iiOut, Double& kernelVolum
message += " ";
- if (near(inputBeam, GaussianBeam(originalParms), 1e-5, casacore::Quantity(1e-2, "arcsec"))) {
+ casacore::Vector const originalParmsV(originalParms);
+ if (near(inputBeam, GaussianBeam(originalParmsV), 1e-5, casacore::Quantity(1e-2, "arcsec"))) {
doConvolve = false;
message += fmt::format("Input beam is already near target resolution so this plane will not be convolved.");
} else {
kernelParms = _getConvolvingBeamForTargetResolution(originalParms, inputBeam);
kernelVolume = _makeKernel(kernel, kernelType, kernelParms, imageIn);
message += fmt::format(": Convolving image which has a beam of {} with a Gaussian of {} to reach a target resolution of {}",
- FormatBeam(inputBeam), FormatBeam(GaussianBeam(kernelParms)), FormatBeam(GaussianBeam(originalParms)));
+ FormatBeam(inputBeam), FormatBeam(GaussianBeam(kernelParmsV)), FormatBeam(GaussianBeam(originalParmsV)));
}
spdlog::debug(message);
@@ -363,12 +368,12 @@ void Image2DConvolver::_doMultipleBeams(ImageInfo& iiOut, Double& kernelVolum
casacore::TempImage subImageOut(subImage.shape(), subImage.coordinates());
if (doConvolve) {
auto scaleFactor = _dealWithRestoringBeam(
- brightnessUnitOut, beamOut, kernel, kernelVolume, kernelType, kernelParms, subCsys, inputBeam, imageIn.units(), i == 0);
+ brightnessUnitOut, beamOut, kernel, kernelVolume, kernelType, kernelParmsV, subCsys, inputBeam, imageIn.units(), i == 0);
{
string message("Scaling pixel values by ");
if (logFactors) {
if (_targetres) {
- casacore::GaussianBeam kernelBeam(kernelParms);
+ casacore::GaussianBeam kernelBeam(kernelParmsV);
factor1 = pixelArea / kernelBeam.getArea("arcsec*arcsec");
}
auto factor2 = beamOut.getArea("arcsec*arcsec") / inputBeam.getArea("arcsec*arcsec");
@@ -438,7 +443,8 @@ template
Double Image2DConvolver::_makeKernel(casacore::Array& kernelArray, casacore::VectorKernel::KernelTypes kernelType,
const std::vector& parameters, const casacore::ImageInterface& imageIn) const {
// Check number of parameters
- _checkKernelParameters(kernelType, parameters);
+ casacore::Vector const parametersV(parameters);
+ _checkKernelParameters(kernelType, parametersV);
// Convert kernel widths to pixels from world. Demands major and minor both in pixels or both in world, else exception
casacore::Vector dParameters;
@@ -744,4 +750,4 @@ void Image2DConvolver::StopCalculation() {
_stop = true;
}
-#endif // CARTA_BACKEND__MOMENT_IMAGE2DCONVOLVER_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_IMAGE2DCONVOLVER_TCC_
diff --git a/src/ImageGenerators/ImageGenerator.h b/src/ImageGenerators/ImageGenerator.h
index 152b09701..eeeaafa7e 100644
--- a/src/ImageGenerators/ImageGenerator.h
+++ b/src/ImageGenerators/ImageGenerator.h
@@ -1,33 +1,26 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEGENERATORS_IMAGEGENERATOR_H_
-#define CARTA_BACKEND_IMAGEGENERATORS_IMAGEGENERATOR_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_IMAGEGENERATOR_H_
+#define CARTA_SRC_IMAGEGENERATORS_IMAGEGENERATOR_H_
#include
#include
-#define MOMENT_ID_MULTIPLIER 1000
-#define PV_ID_MULTIPLIER -1000
-#define FITTING_ID_MULTIPLIER -1000
-#define FITTING_WITH_MOMENT_ID_MULTIPLIER -10
-
using GeneratorProgressCallback = std::function;
namespace carta {
struct GeneratedImage {
- int file_id;
std::string name;
std::shared_ptr> image;
GeneratedImage() {}
- GeneratedImage(int file_id_, std::string name_, std::shared_ptr> image_) {
- file_id = file_id_;
+ GeneratedImage(std::string name_, std::shared_ptr> image_) {
name = name_;
image = image_;
}
@@ -35,4 +28,4 @@ struct GeneratedImage {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEGENERATORS_IMAGEGENERATOR_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_IMAGEGENERATOR_H_
diff --git a/src/ImageGenerators/ImageMoments.h b/src/ImageGenerators/ImageMoments.h
index d163cb81a..fbcdd8aa5 100644
--- a/src/ImageGenerators/ImageMoments.h
+++ b/src/ImageGenerators/ImageMoments.h
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//
// Re-write from the file: "carta-casacore/casa6/casa5/code/imageanalysis/ImageAnalysis/ImageMoments.h"
//
-#ifndef CARTA_BACKEND__MOMENT_IMAGEMOMENTS_H_
-#define CARTA_BACKEND__MOMENT_IMAGEMOMENTS_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_H_
+#define CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_H_
#include
#include
@@ -128,4 +128,4 @@ class ImageMoments : public casa::MomentsBase {
#include "ImageMoments.tcc"
-#endif // CARTA_BACKEND__MOMENT_IMAGEMOMENTS_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_H_
diff --git a/src/ImageGenerators/ImageMoments.tcc b/src/ImageGenerators/ImageMoments.tcc
index 98f17470e..8bf02bcaa 100644
--- a/src/ImageGenerators/ImageMoments.tcc
+++ b/src/ImageGenerators/ImageMoments.tcc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -7,8 +7,8 @@
//
// Re-write from the file: "carta-casacore/casa6/casa5/code/imageanalysis/ImageAnalysis/ImageMoments.tcc"
//
-#ifndef CARTA_BACKEND__MOMENT_IMAGEMOMENTS_TCC_
-#define CARTA_BACKEND__MOMENT_IMAGEMOMENTS_TCC_
+#ifndef CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_TCC_
+#define CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_TCC_
#include "../Logger/Logger.h"
#include "Util/Casacore.h"
@@ -28,8 +28,7 @@ ImageMoments::ImageMoments(const casacore::ImageInterface& image, casacore
template
casacore::Bool ImageMoments::SetNewImage(const casacore::ImageInterface& image) {
- T* dummy = nullptr;
- casacore::DataType imageType = casacore::whatType(dummy);
+ casacore::DataType imageType = casacore::whatType();
ThrowIf(imageType != casacore::TpFloat && imageType != casacore::TpDouble,
"Moments can only be evaluated for Float or Double valued images");
@@ -728,4 +727,4 @@ casacore::IPosition ImageMoments::ChunkShape(casacore::uInt axis, const casac
return chunk_shape;
}
-#endif // CARTA_BACKEND__MOMENT_IMAGEMOMENTS_TCC_
+#endif // CARTA_SRC_IMAGEGENERATORS_IMAGEMOMENTS_TCC_
diff --git a/src/ImageGenerators/MomentGenerator.cc b/src/ImageGenerators/MomentGenerator.cc
index 1e1b36c8c..bb062d1b5 100644
--- a/src/ImageGenerators/MomentGenerator.cc
+++ b/src/ImageGenerators/MomentGenerator.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -75,17 +75,13 @@ bool MomentGenerator::CalculateMoments(int file_id, const casacore::ImageRegion&
out_file_name += std::to_string(name_index);
}
- // Set a temp moment file Id.
- // With each name index, advance by number of moment types to avoid duplicates.
- int moment_file_id = (file_id + 1) * MOMENT_ID_MULTIPLIER + (name_index * _moment_map.size()) + moment_type;
-
// Fill results
std::shared_ptr> moment_image =
dynamic_pointer_cast>(result_images[i]);
// Add moment requests info to an image header as the HISTORY key
moment_image->appendLog(_logger);
- collapse_results.push_back(GeneratedImage(moment_file_id, out_file_name, moment_image));
+ collapse_results.push_back(GeneratedImage(out_file_name, moment_image));
}
_success = true;
} catch (const AipsError& x) {
diff --git a/src/ImageGenerators/MomentGenerator.h b/src/ImageGenerators/MomentGenerator.h
index 2d5c05a28..eda5c466c 100644
--- a/src/ImageGenerators/MomentGenerator.h
+++ b/src/ImageGenerators/MomentGenerator.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_MOMENT_MOMENTGENERATOR_H_
-#define CARTA_BACKEND_MOMENT_MOMENTGENERATOR_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_MOMENTGENERATOR_H_
+#define CARTA_SRC_IMAGEGENERATORS_MOMENTGENERATOR_H_
#include
#include
@@ -89,4 +89,4 @@ class MomentGenerator : public casa::ImageMomentsProgressMonitor {
} // namespace carta
-#endif // CARTA_BACKEND_MOMENT_MOMENTGENERATOR_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_MOMENTGENERATOR_H_
diff --git a/src/ImageGenerators/PvGenerator.cc b/src/ImageGenerators/PvGenerator.cc
index 6f8c71bb1..c0de88ed9 100644
--- a/src/ImageGenerators/PvGenerator.cc
+++ b/src/ImageGenerators/PvGenerator.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -15,11 +15,10 @@
using namespace carta;
-PvGenerator::PvGenerator() : _file_id(0), _name("") {}
+PvGenerator::PvGenerator() : _name("") {}
-void PvGenerator::SetFileIdName(int file_id, int index, const std::string& filename, bool is_preview) {
+void PvGenerator::SetFileName(int index, const std::string& filename, bool is_preview) {
// Optional (not for preview) file id, and name for PV image
- _file_id = ((file_id + 1) * PV_ID_MULTIPLIER) - index;
SetPvImageName(filename, index, is_preview);
}
@@ -49,7 +48,7 @@ bool PvGenerator::GetPvImage(const std::shared_ptr & frame, const casacore
image->flush();
// Set returned image
- pv_image = GeneratedImage(_file_id, _name, image);
+ pv_image = GeneratedImage(_name, image);
return true;
}
diff --git a/src/ImageGenerators/PvGenerator.h b/src/ImageGenerators/PvGenerator.h
index 6751326e6..d746cdc93 100644
--- a/src/ImageGenerators/PvGenerator.h
+++ b/src/ImageGenerators/PvGenerator.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEGENERATORS_PVGENERATOR_H_
-#define CARTA_BACKEND_IMAGEGENERATORS_PVGENERATOR_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_PVGENERATOR_H_
+#define CARTA_SRC_IMAGEGENERATORS_PVGENERATOR_H_
#include
#include
@@ -24,7 +24,7 @@ class PvGenerator {
~PvGenerator() = default;
// For PV generator (not preview)
- void SetFileIdName(int file_id, int index, const std::string& filename, bool is_preview = false);
+ void SetFileName(int index, const std::string& filename, bool is_preview = false);
// Create generated PV image from input data. If reverse, [spectral, offset] instead of normal [offset, spectral].
// Returns generated image and success, with message if failure.
@@ -49,4 +49,4 @@ class PvGenerator {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEGENERATORS_PVGENERATOR_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_PVGENERATOR_H_
diff --git a/src/ImageGenerators/PvPreviewCube.cc b/src/ImageGenerators/PvPreviewCube.cc
index 61429ff82..394716d93 100644
--- a/src/ImageGenerators/PvPreviewCube.cc
+++ b/src/ImageGenerators/PvPreviewCube.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -12,6 +12,7 @@
#include
#include "DataStream/Smoothing.h"
+#include "Logger/Logger.h"
#include "Timer/Timer.h"
#define LOAD_DATA_PROGRESS_INTERVAL 1000
@@ -162,8 +163,8 @@ bool PvPreviewCube::GetRegionProfile(const casacore::Slicer& region_bounding_box
auto box_start = region_bounding_box.start();
auto box_length = region_bounding_box.length();
- // Initialize profile
- size_t nchan = box_length(_preview_image->coordinates().spectralAxisNumber());
+ // Initialize profile to channels in preview image
+ size_t nchan = _preview_image->shape()(_preview_image->coordinates().spectralAxisNumber());
profile.resize(nchan, NAN);
std::vector npix_per_chan(nchan, 0.0);
auto data_shape = _cube_data.shape();
diff --git a/src/ImageGenerators/PvPreviewCube.h b/src/ImageGenerators/PvPreviewCube.h
index 6fdafbbe5..32622317d 100644
--- a/src/ImageGenerators/PvPreviewCube.h
+++ b/src/ImageGenerators/PvPreviewCube.h
@@ -1,19 +1,19 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUBE_H_
-#define CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUBE_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUBE_H_
+#define CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUBE_H_
+
+#include
#include "ImageGenerators/ImageGenerator.h"
#include "Region/Region.h"
#include "Util/File.h"
#include "Util/Image.h"
-#include
-
namespace carta {
struct PreviewCubeParameters {
@@ -115,4 +115,4 @@ class PvPreviewCube {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUBE_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUBE_H_
diff --git a/src/ImageGenerators/PvPreviewCut.cc b/src/ImageGenerators/PvPreviewCut.cc
index e031b5974..f9bb12f1b 100644
--- a/src/ImageGenerators/PvPreviewCut.cc
+++ b/src/ImageGenerators/PvPreviewCut.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageGenerators/PvPreviewCut.h b/src/ImageGenerators/PvPreviewCut.h
index 3f87d249b..6e4fc667a 100644
--- a/src/ImageGenerators/PvPreviewCut.h
+++ b/src/ImageGenerators/PvPreviewCut.h
@@ -1,11 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUT_H_
-#define CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUT_H_
+#ifndef CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUT_H_
+#define CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUT_H_
+
+#include
#include "Region/Region.h"
#include "Util/File.h"
@@ -88,4 +90,4 @@ class PvPreviewCut {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGEGENERATORS_PVPREVIEWCUT_H_
+#endif // CARTA_SRC_IMAGEGENERATORS_PVPREVIEWCUT_H_
diff --git a/src/ImageStats/BasicStatsCalculator.h b/src/ImageStats/BasicStatsCalculator.h
index 6316c33ea..7797784e6 100644
--- a/src/ImageStats/BasicStatsCalculator.h
+++ b/src/ImageStats/BasicStatsCalculator.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_H_
-#define CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_H_
+#ifndef CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_H_
+#define CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_H_
#include
#include
@@ -81,4 +81,4 @@ class BasicStatsCalculator {
#include "BasicStatsCalculator.tcc"
-#endif // CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_H_
+#endif // CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_H_
diff --git a/src/ImageStats/BasicStatsCalculator.tcc b/src/ImageStats/BasicStatsCalculator.tcc
index 40c44a22a..34b043599 100644
--- a/src/ImageStats/BasicStatsCalculator.tcc
+++ b/src/ImageStats/BasicStatsCalculator.tcc
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
-#define CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
+#ifndef CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
+#define CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
#include "Logger/Logger.h"
@@ -102,4 +102,4 @@ BasicStats BasicStatsCalculator::GetStats() const {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
+#endif // CARTA_SRC_IMAGESTATS_BASICSTATSCALCULATOR_TCC_
diff --git a/src/ImageStats/Histogram.cc b/src/ImageStats/Histogram.cc
index 9e62c0df6..f9fa7f6ee 100644
--- a/src/ImageStats/Histogram.cc
+++ b/src/ImageStats/Histogram.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageStats/Histogram.h b/src/ImageStats/Histogram.h
index d8473f06c..f0fb9d11a 100644
--- a/src/ImageStats/Histogram.h
+++ b/src/ImageStats/Histogram.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_IMAGESTATS_HISTOGRAM_H_
-#define CARTA_BACKEND_IMAGESTATS_HISTOGRAM_H_
+#ifndef CARTA_SRC_IMAGESTATS_HISTOGRAM_H_
+#define CARTA_SRC_IMAGESTATS_HISTOGRAM_H_
#include "BasicStatsCalculator.h"
@@ -61,4 +61,4 @@ class Histogram {
} // namespace carta
-#endif // CARTA_BACKEND_IMAGESTATS_HISTOGRAM_H_
+#endif // CARTA_SRC_IMAGESTATS_HISTOGRAM_H_
diff --git a/src/ImageStats/StatsCalculator.cc b/src/ImageStats/StatsCalculator.cc
index a93ac1293..310a508fe 100644
--- a/src/ImageStats/StatsCalculator.cc
+++ b/src/ImageStats/StatsCalculator.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/ImageStats/StatsCalculator.h b/src/ImageStats/StatsCalculator.h
index c86aa7d3c..72271be4f 100644
--- a/src/ImageStats/StatsCalculator.h
+++ b/src/ImageStats/StatsCalculator.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# StatsCalculator.h: functions for calculating statistics and histograms
-#ifndef CARTA_BACKEND_IMAGESTATS_STATSCALCULATOR_H_
-#define CARTA_BACKEND_IMAGESTATS_STATSCALCULATOR_H_
+#ifndef CARTA_SRC_IMAGESTATS_STATSCALCULATOR_H_
+#define CARTA_SRC_IMAGESTATS_STATSCALCULATOR_H_
#include
@@ -28,4 +28,4 @@ bool CalcStatsValues(std::map>& stats_valu
} // namespace carta
-#endif // CARTA_BACKEND_IMAGESTATS_STATSCALCULATOR_H_
+#endif // CARTA_SRC_IMAGESTATS_STATSCALCULATOR_H_
diff --git a/src/Logger/CartaLogSink.cc b/src/Logger/CartaLogSink.cc
new file mode 100644
index 000000000..8c3acfb99
--- /dev/null
+++ b/src/Logger/CartaLogSink.cc
@@ -0,0 +1,44 @@
+/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
+ SPDX-License-Identifier: GPL-3.0-or-later
+*/
+
+#include "CartaLogSink.h"
+#include "Logger.h"
+
+#include
+#include
+
+namespace carta {
+
+CartaLogSink::CartaLogSink(casacore::LogMessage::Priority filter) : casacore::LogSinkInterface(casacore::LogFilter(filter)) {}
+
+bool CartaLogSink::postLocally(const casacore::LogMessage& message) {
+ if (filter().pass(message)) {
+ auto priority = message.priority();
+ auto log_message = "[casacore] " + message.message();
+ if (message.priority() <= casacore::LogMessage::DEBUG1) {
+ spdlog::debug(log_message);
+ } else if (priority <= casacore::LogMessage::NORMAL) {
+ spdlog::info(log_message);
+ } else if (priority == casacore::LogMessage::WARN) {
+ spdlog::warn(log_message);
+ } else {
+ spdlog::error(log_message);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+casacore::String CartaLogSink::localId() {
+ return casacore::String("CartaLogSink");
+}
+
+casacore::String CartaLogSink::id() const {
+ return casacore::String("CartaLogSink");
+}
+
+} // namespace carta
diff --git a/src/Logger/CartaLogSink.h b/src/Logger/CartaLogSink.h
new file mode 100644
index 000000000..c7e9a6a23
--- /dev/null
+++ b/src/Logger/CartaLogSink.h
@@ -0,0 +1,35 @@
+/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
+ SPDX-License-Identifier: GPL-3.0-or-later
+*/
+
+#ifndef CARTA_SRC_LOGGER_CARTALOGSINK_H_
+#define CARTA_SRC_LOGGER_CARTALOGSINK_H_
+
+#include
+
+namespace carta {
+
+class CartaLogSink : public casacore::LogSinkInterface {
+public:
+ CartaLogSink() = default;
+ explicit CartaLogSink(casacore::LogMessage::Priority filter);
+ ~CartaLogSink() = default;
+
+ // Write message to the spdlog if it passes the filter.
+ virtual bool postLocally(const casacore::LogMessage& message);
+
+ // OVERRIDE? Write any pending output.
+ // virtual void flush (bool global=True) override;
+
+ // Returns the id for this class.
+ static casacore::String localId();
+
+ // Returns the id of the LogSink in use.
+ virtual casacore::String id() const;
+};
+
+} // namespace carta
+
+#endif // CARTA_SRC_LOGGER_CARTALOGSINK_H_
diff --git a/src/Logger/Logger.cc b/src/Logger/Logger.cc
index 57d6dd517..f2ea51392 100644
--- a/src/Logger/Logger.cc
+++ b/src/Logger/Logger.cc
@@ -1,11 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "Logger.h"
+#include "Main/ProgramSettings.h"
+
#include
namespace carta {
@@ -13,8 +15,14 @@ namespace logger {
static bool log_protocol_messages(false);
-void InitLogger(bool no_log_file, int verbosity, bool log_performance, bool log_protocol_messages_, fs::path user_directory) {
- log_protocol_messages = log_protocol_messages_;
+void InitLogger() {
+ // Copy parameters from the global settings
+ auto& settings = ProgramSettings::GetInstance();
+ log_protocol_messages = settings.log_protocol_messages;
+ auto no_log = settings.no_log;
+ auto user_directory = settings.user_directory;
+ auto verbosity = settings.verbosity;
+ auto log_performance = settings.log_performance;
// Set the stdout/stderr console
auto console_sink = std::make_shared();
@@ -26,11 +34,11 @@ void InitLogger(bool no_log_file, int verbosity, bool log_performance, bool log_
// Set a log file with its full name, maximum size and the number of rotated files
std::string log_fullname;
- if (!no_log_file) {
+ if (!no_log) {
log_fullname = (user_directory / "log/carta.log").string();
auto stdout_log_file_sink = std::make_shared(log_fullname, LOG_FILE_SIZE, ROTATED_LOG_FILES);
stdout_log_file_sink->set_formatter(
- std::make_unique(CARTA_LOGGER_PATTERN, spdlog::pattern_time_type::utc));
+ std::make_unique(CARTA_FILE_LOGGER_PATTERN, spdlog::pattern_time_type::utc));
console_sinks.push_back(stdout_log_file_sink);
}
@@ -72,7 +80,7 @@ void InitLogger(bool no_log_file, int verbosity, bool log_performance, bool log_
// Set as the default logger
spdlog::set_default_logger(default_logger);
- if (!no_log_file) {
+ if (!no_log) {
spdlog::info("Writing to the log file: {}", log_fullname);
}
@@ -87,7 +95,7 @@ void InitLogger(bool no_log_file, int verbosity, bool log_performance, bool log_
// Set a log file with its full name, maximum size and the number of rotated files
std::string perf_log_fullname;
- if (!no_log_file) {
+ if (!no_log) {
perf_log_fullname = (user_directory / "log/performance.log").string();
auto perf_log_file_sink =
std::make_shared(perf_log_fullname, LOG_FILE_SIZE, ROTATED_LOG_FILES);
diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h
index ffd4ec1bb..63125d3df 100644
--- a/src/Logger/Logger.h
+++ b/src/Logger/Logger.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_LOGGER_LOGGER_H_
-#define CARTA_BACKEND_LOGGER_LOGGER_H_
+#ifndef CARTA_SRC_LOGGER_LOGGER_H_
+#define CARTA_SRC_LOGGER_LOGGER_H_
#include
@@ -19,12 +19,14 @@
#include "Util/FileSystem.h"
+// Time format Z is zero UTC offset (ISO 8601)
#define LOG_FILE_SIZE 1024 * 1024 * 5 // (Bytes)
#define ROTATED_LOG_FILES 5
#define CARTA_LOGGER_TAG "CARTA"
-#define CARTA_LOGGER_PATTERN "[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v"
+#define CARTA_LOGGER_PATTERN "[%Y-%m-%d %H:%M:%S.%eZ] [%n] [%^%l%$] %v"
+#define CARTA_FILE_LOGGER_PATTERN "[%Y-%m-%d %H:%M:%S.%eZ] [%^%l%$] %v"
#define PERF_TAG "performance"
-#define PERF_PATTERN "[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [%n] %v"
+#define PERF_PATTERN "[%Y-%m-%d %H:%M:%S.%eZ] [%^%l%$] [%n] %v"
// customize the log function for performance
namespace spdlog {
@@ -48,7 +50,7 @@ class carta_sink : public ansicolor_sink {
carta_sink()
: ansicolor_sink(stdout, color_mode::automatic),
mutex_(details::console_mutex::mutex()),
- formatter_(details::make_unique(pattern_time_type::utc)) {
+ formatter_(details::make_unique(CARTA_LOGGER_PATTERN, pattern_time_type::utc)) {
target_file_ = stdout;
colors_[level::trace] = to_string_(white);
colors_[level::debug] = to_string_(cyan);
@@ -108,11 +110,11 @@ class carta_sink : public ansicolor_sink {
namespace carta {
namespace logger {
-void InitLogger(bool no_log_file, int verbosity, bool log_performance, bool log_protocol_messages_, fs::path user_directory);
+void InitLogger();
void LogReceivedEventType(const CARTA::EventType& event_type);
void LogSentEventType(const CARTA::EventType& event_type);
void FlushLogFile();
} // namespace logger
} // namespace carta
-#endif // CARTA_BACKEND_LOGGER_LOGGER_H_
+#endif // CARTA_SRC_LOGGER_LOGGER_H_
diff --git a/src/Main/Main.cc b/src/Main/Main.cc
index 60991f064..4ac705ed3 100644
--- a/src/Main/Main.cc
+++ b/src/Main/Main.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -11,6 +11,7 @@
#include "FileList/FileListHandler.h"
#include "HttpServer/HttpServer.h"
+#include "Logger/CartaLogSink.h"
#include "Logger/Logger.h"
#include "ProgramSettings.h"
#include "Session/SessionManager.h"
@@ -20,6 +21,9 @@
#include "Util/Token.h"
#include "WebBrowser.h"
+#include
+#include
+
// Entry point. Parses command line arguments and starts server listening
int main(int argc, char* argv[]) {
std::shared_ptr file_list_handler;
@@ -42,16 +46,38 @@ int main(int argc, char* argv[]) {
sigaction(SIGINT, &sig_handler, nullptr);
// Main
- carta::ProgramSettings settings(argc, argv);
+ auto settings = ProgramSettings::Initialise(argc, argv);
if (settings.help || settings.version) {
exit(0);
}
- carta::logger::InitLogger(
- settings.no_log, settings.verbosity, settings.log_performance, settings.log_protocol_messages, settings.user_directory);
+ carta::logger::InitLogger();
settings.FlushMessages(); // flush log messages produced during Program Settings setup
+ // Send casacore log messages (global and local) to sink.
+ // CartaLogSink sends messages to spdlog, NullLogSink discards messages.
+ casacore::LogSinkInterface* carta_log_sink(nullptr);
+ switch (settings.verbosity) {
+ case 0:
+ carta_log_sink = new casacore::NullLogSink();
+ break;
+ case 1:
+ case 2:
+ carta_log_sink = new CartaLogSink(casacore::LogMessage::SEVERE);
+ break;
+ case 3:
+ carta_log_sink = new CartaLogSink(casacore::LogMessage::WARN);
+ break;
+ case 4:
+ case 5:
+ default:
+ carta_log_sink = new CartaLogSink(casacore::LogMessage::NORMAL);
+ }
+ casacore::LogSink log_sink(carta_log_sink->filter(), std::shared_ptr(carta_log_sink));
+ casacore::LogSink::globalSink(carta_log_sink);
+ casacore::LogIO casacore_log(log_sink);
+
if (settings.wait_time >= 0) {
Session::SetExitTimeout(settings.wait_time);
}
diff --git a/src/Main/ProgramSettings.cc b/src/Main/ProgramSettings.cc
index 4ea949a5c..71f8a1cf4 100644
--- a/src/Main/ProgramSettings.cc
+++ b/src/Main/ProgramSettings.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -422,12 +422,4 @@ void ProgramSettings::AddDeprecationWarning(const std::string& option, std::stri
warning_msgs.push_back(fmt::format("Option {} found in {} is deprecated. {}", option, where, message));
}
-bool ProgramSettings::operator!=(const ProgramSettings& rhs) const {
- return GetTuple() != rhs.GetTuple();
-}
-
-bool ProgramSettings::operator==(const ProgramSettings& rhs) const {
- return GetTuple() == rhs.GetTuple();
-}
-
} // namespace carta
diff --git a/src/Main/ProgramSettings.h b/src/Main/ProgramSettings.h
index 31771300c..313ef1c0d 100644
--- a/src/Main/ProgramSettings.h
+++ b/src/Main/ProgramSettings.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_SRC_MAIN_PROGRAMSETTINGS_H_
-#define CARTA_BACKEND_SRC_MAIN_PROGRAMSETTINGS_H_
+#ifndef CARTA_SRC_MAIN_PROGRAMSETTINGS_H_
+#define CARTA_SRC_MAIN_PROGRAMSETTINGS_H_
#include
#include
@@ -31,6 +31,15 @@
namespace carta {
struct ProgramSettings {
+ static ProgramSettings& GetInstance() {
+ static ProgramSettings settings;
+ return settings;
+ }
+
+ static ProgramSettings& Initialise(int argc, char** argv) {
+ return GetInstance() = std::move(carta::ProgramSettings(argc, argv));
+ }
+
bool version = false;
bool help = false;
std::vector port;
@@ -122,15 +131,6 @@ struct ProgramSettings {
void SetSettingsFromJSON(const nlohmann::json& j);
void PushFilePaths();
- // TODO: this is outdated. It's used by the equality operator, which is used by a test.
- auto GetTuple() const {
- return std::tie(help, version, port, omp_thread_count, top_level_folder, starting_folder, host, files, frontend_folder, no_http,
- no_browser, no_log, log_performance, log_protocol_messages, debug_no_auth, controller_deployment, verbosity, wait_time,
- init_wait_time, idle_session_wait_time);
- }
- bool operator!=(const ProgramSettings& rhs) const;
- bool operator==(const ProgramSettings& rhs) const;
-
std::vector warning_msgs;
std::vector debug_msgs;
void FlushMessages() {
@@ -141,4 +141,4 @@ struct ProgramSettings {
}
};
} // namespace carta
-#endif // CARTA_BACKEND_SRC_MAIN_PROGRAMSETTINGS_H_
+#endif // CARTA_SRC_MAIN_PROGRAMSETTINGS_H_
diff --git a/src/Main/WebBrowser.cc b/src/Main/WebBrowser.cc
index 55c555f8f..06ff09a15 100644
--- a/src/Main/WebBrowser.cc
+++ b/src/Main/WebBrowser.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/Main/WebBrowser.h b/src/Main/WebBrowser.h
index 0bc35a719..566886c96 100644
--- a/src/Main/WebBrowser.h
+++ b/src/Main/WebBrowser.h
@@ -1,11 +1,11 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
-#ifndef CARTA_BACKEND_SRC_SESSIONMANAGER_WEBBROWSER_H_
-#define CARTA_BACKEND_SRC_SESSIONMANAGER_WEBBROWSER_H_
+#ifndef CARTA_SRC_MAIN_WEBBROWSER_H_
+#define CARTA_SRC_MAIN_WEBBROWSER_H_
#include
#include
@@ -36,4 +36,4 @@ class WebBrowser {
} // namespace carta
-#endif // CARTA_BACKEND_SRC_SESSIONMANAGER_WEBBROWSER_H_
+#endif // CARTA_SRC_MAIN_WEBBROWSER_H_
diff --git a/src/Region/CrtfImportExport.cc b/src/Region/CrtfImportExport.cc
index 4a883fa5a..ba3957628 100644
--- a/src/Region/CrtfImportExport.cc
+++ b/src/Region/CrtfImportExport.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -451,7 +451,6 @@ void CrtfImportExport::ProcessFileLines(std::vector& lines) {
std::vector parameters;
std::unordered_map properties;
ParseRegionParameters(line, parameters, properties);
-
// Coordinate frame for world coordinates conversion
RegionState region_state;
CARTA::RegionStyle region_style;
@@ -499,7 +498,13 @@ void CrtfImportExport::ProcessFileLines(std::vector& lines) {
if (region == "text") {
// Set text label for text region
if (parameters.size() == 4) { // text, x, y, "text"
- region_style.mutable_annotation_style()->set_text_label0(parameters[3]);
+ std::string label(parameters[3]);
+ if (!label.empty() &&
+ ((label.front() == '"' && label.back() == '"') || (label.front() == '\'' && label.back() == '\''))) {
+ label.pop_back();
+ label = label.substr(1);
+ }
+ region_style.mutable_annotation_style()->set_text_label0(label);
}
} else {
// Set text position for textbox region
diff --git a/src/Region/CrtfImportExport.h b/src/Region/CrtfImportExport.h
index b3135541f..ec89b2b9b 100644
--- a/src/Region/CrtfImportExport.h
+++ b/src/Region/CrtfImportExport.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# CrtfImportExport.h: handle CRTF region file import and export
-#ifndef CARTA_BACKEND_REGION_CRTFIMPORTEXPORT_H_
-#define CARTA_BACKEND_REGION_CRTFIMPORTEXPORT_H_
+#ifndef CARTA_SRC_REGION_CRTFIMPORTEXPORT_H_
+#define CARTA_SRC_REGION_CRTFIMPORTEXPORT_H_
#include
#include
@@ -101,4 +101,4 @@ class CrtfImportExport : public RegionImportExport {
} // namespace carta
-#endif // CARTA_BACKEND_REGION_CRTFIMPORTEXPORT_H_
+#endif // CARTA_SRC_REGION_CRTFIMPORTEXPORT_H_
diff --git a/src/Region/Ds9ImportExport.cc b/src/Region/Ds9ImportExport.cc
index 47a39c103..89bc2c6d8 100644
--- a/src/Region/Ds9ImportExport.cc
+++ b/src/Region/Ds9ImportExport.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
diff --git a/src/Region/Ds9ImportExport.h b/src/Region/Ds9ImportExport.h
index cea3146e2..3a6771b54 100644
--- a/src/Region/Ds9ImportExport.h
+++ b/src/Region/Ds9ImportExport.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
//# Ds9ImportExport.h: handle DS9 region file import and export
-#ifndef CARTA_BACKEND_REGION_DS9IMPORTEXPORT_H_
-#define CARTA_BACKEND_REGION_DS9IMPORTEXPORT_H_
+#ifndef CARTA_SRC_REGION_DS9IMPORTEXPORT_H_
+#define CARTA_SRC_REGION_DS9IMPORTEXPORT_H_
#include
#include
@@ -105,4 +105,4 @@ class Ds9ImportExport : public RegionImportExport {
} // namespace carta
-#endif // CARTA_BACKEND_REGION_DS9IMPORTEXPORT_H_
+#endif // CARTA_SRC_REGION_DS9IMPORTEXPORT_H_
diff --git a/src/Region/LineBoxRegions.cc b/src/Region/LineBoxRegions.cc
index 112fa2441..f0e893483 100644
--- a/src/Region/LineBoxRegions.cc
+++ b/src/Region/LineBoxRegions.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -11,6 +11,7 @@
#include
#include "Logger/Logger.h"
+#include "Util/Message.h"
namespace carta {
@@ -232,10 +233,11 @@ double LineBoxRegions::GetPointSeparation(
std::shared_ptr coord_sys, const std::vector& point1, const std::vector& point2) {
// Returns angular separation in arcsec. Both points must be inside image or returns zero (use GetWorldLength instead, not as accurate).
double separation(0.0);
+ casacore::Vector const point1_v(point1), point2_v(point2);
std::lock_guard guard(_mvdir_mutex);
try {
- casacore::MVDirection mvdir1 = coord_sys->directionCoordinate().toWorld(point1);
- casacore::MVDirection mvdir2 = coord_sys->directionCoordinate().toWorld(point2);
+ casacore::MVDirection mvdir1 = coord_sys->directionCoordinate().toWorld(point1_v);
+ casacore::MVDirection mvdir2 = coord_sys->directionCoordinate().toWorld(point2_v);
separation = mvdir1.separation(mvdir2, "arcsec").getValue();
} catch (casacore::AipsError& err) {
// invalid pixel coordinates - outside image
diff --git a/src/Region/LineBoxRegions.h b/src/Region/LineBoxRegions.h
index 873f4d7ad..c5f7edd9b 100644
--- a/src/Region/LineBoxRegions.h
+++ b/src/Region/LineBoxRegions.h
@@ -1,13 +1,13 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
// LineBoxRegions.h: class to approximate line with width as series of box regions
-#ifndef CARTA_BACKEND_REGION_LINEBOXREGIONS_H_
-#define CARTA_BACKEND_REGION_LINEBOXREGIONS_H_
+#ifndef CARTA_SRC_REGION_LINEBOXREGIONS_H_
+#define CARTA_SRC_REGION_LINEBOXREGIONS_H_
#include
@@ -55,4 +55,4 @@ class LineBoxRegions {
} // namespace carta
-#endif // CARTA_BACKEND_REGION_LINEBOXREGIONS_H_
+#endif // CARTA_SRC_REGION_LINEBOXREGIONS_H_
diff --git a/src/Region/Region.cc b/src/Region/Region.cc
index d855c1c75..daf47ffd3 100644
--- a/src/Region/Region.cc
+++ b/src/Region/Region.cc
@@ -1,5 +1,5 @@
/* This file is part of the CARTA Image Viewer: https://github.com/CARTAvis/carta-backend
- Copyright 2018-2022 Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
+ Copyright 2018- Academia Sinica Institute of Astronomy and Astrophysics (ASIAA),
Associated Universities, Inc. (AUI) and the Inter-University Institute for Data Intensive Astronomy (IDIA)
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -8,28 +8,15 @@
#include "Region.h"
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
-#include
-#include
+#include
-#include "../Logger/Logger.h"
-#include "Util/Image.h"
+#include "RegionConverter.h"
using namespace carta;
Region::Region(const RegionState& state, std::shared_ptr csys)
- : _coord_sys(csys), _valid(false), _region_changed(false), _reference_region_set(false), _region_state(state) {
+ : _coord_sys(csys), _valid(false), _region_changed(false), _lcregion_set(false), _region_state(state) {
_valid = CheckPoints(state.control_points, state.type);
}
@@ -60,12 +47,10 @@ bool Region::UpdateRegion(const RegionState& new_state) {
void Region::ResetRegionCache() {
// Invalid when region changes
- _reference_region_set = false;
- std::lock_guard guard(_region_mutex);
- _wcs_control_points.clear();
- _reference_region.reset();
- _applied_regions.clear();
- _polygon_regions.clear();
+ std::lock_guard guard(_lcregion_mutex);
+ _lcregion.reset();
+ _lcregion_set = false;
+ _region_converter.reset();
}
// *************************************************************************
@@ -128,6 +113,7 @@ bool Region::PointsFinite(const std::vector& points) {
return points_finite;
}
+// *************************************************************************
// Region connection state (disconnected when region closed)
bool Region::IsConnected() {
@@ -139,644 +125,94 @@ void Region::WaitForTaskCancellation() { // to interrupt the running jobs in the
std::unique_lock lock(GetActiveTaskMutex());
}
-// ******************************************************************************************
-// Apply region to reference image in world coordinates (WCRegion) and save wcs control points
-
-bool Region::ReferenceRegionValid() {
- return _reference_region_set && bool(_reference_region);
-}
-
-void Region::SetReferenceRegion() {
- // Create WCRegion (world coordinate region) in the reference image according to type using wcs control points
- // Sets _reference_region (maybe to nullptr) or _reference_annotation
- casacore::WCRegion* region(nullptr);
- auto region_state = GetRegionState();
- std::vector pixel_points(region_state.control_points);
- std::vector world_points; // point holder; one CARTA point is two world points (x, y)
- casacore::IPosition pixel_axes(2, 0, 1);
- casacore::Vector abs_rel;
- auto type(region_state.type);
- try {
- switch (type) {
- case CARTA::POINT:
- case CARTA::ANNPOINT: {
- if (ConvertCartaPointToWorld(pixel_points[0], _wcs_control_points)) {
- // WCBox blc and trc are same point
- std::lock_guard guard(_region_mutex);
- region = new casacore::WCBox(_wcs_control_points, _wcs_control_points, pixel_axes, *_coord_sys, abs_rel);
- }
- break;
- }
- case CARTA::RECTANGLE: // 4 corners
- case CARTA::POLYGON: // vertices
- case CARTA::ANNRECTANGLE: // 4 corners
- case CARTA::ANNPOLYGON: // vertices
- case CARTA::ANNTEXT: { // 4 corners of text box
- if (type == CARTA::RECTANGLE || type == CARTA::ANNRECTANGLE || type == CARTA::ANNTEXT) {
- if (!RectanglePointsToWorld(pixel_points, _wcs_control_points)) {
- _wcs_control_points.clear();
- }
- } else {
- for (auto& point : pixel_points) {
- if (ConvertCartaPointToWorld(point, world_points)) {
- _wcs_control_points.push_back(world_points[0]);
- _wcs_control_points.push_back(world_points[1]);
- } else {
- _wcs_control_points.clear();
- break;
- }
- }
- }
-
- if (!_wcs_control_points.empty()) {
- // separate x and y in control points, convert from Vector to Quantum
- std::vector x, y;
- for (size_t i = 0; i < _wcs_control_points.size(); i += 2) {
- x.push_back(_wcs_control_points[i].getValue());
- y.push_back(_wcs_control_points[i + 1].getValue());
- }
- casacore::Vector vx(x), vy(y);
- casacore::Quantum> qx, qy;
-
- casacore::Vector world_units = _coord_sys->worldAxisUnits();
-
- qx = vx; // set values
- qx.setUnit(world_units(0)); // set unit
- qy = vy; // set values
- qy.setUnit(world_units(1)); // set unit
-
- std::lock_guard guard(_region_mutex);
- region = new casacore::WCPolygon(qx, qy, pixel_axes, *_coord_sys);
- }
- break;
- }
- case CARTA::ELLIPSE:
- case CARTA::ANNELLIPSE: // [(cx, cy), (bmaj, bmin)]
- case CARTA::ANNCOMPASS: { // [(cx, cy), (length, length)}
- float ellipse_rotation;
- if (EllipsePointsToWorld(pixel_points, _wcs_control_points, ellipse_rotation)) {
- // control points are in order: xcenter, ycenter, major axis, minor axis
- casacore::Quantity theta(ellipse_rotation, "deg");
- theta.convert("rad");
- std::lock_guard guard(_region_mutex);
- region = new casacore::WCEllipsoid(_wcs_control_points[0], _wcs_control_points[1], _wcs_control_points[2],
- _wcs_control_points[3], theta, 0, 1, *_coord_sys);
- }
- break;
- }
- default:
- break;
- }
- } catch (casacore::AipsError& err) { // region failed
- spdlog::error("{} region failed: {}", RegionName(type), err.getMesg());
- }
-
- std::shared_ptr shared_region = std::shared_ptr(region);
- std::atomic_store(&_reference_region, shared_region);
-
- // Flag indicates that attempt was made, to avoid repeated attempts
- _reference_region_set = true;
-}
-
-bool Region::RectanglePointsToWorld(std::vector& pixel_points, std::vector& wcs_points) {
- // Convert CARTA rectangle points (cx, cy), (width, height) to world coordinates
- if (pixel_points.size() != 2) {
- return false;
- }
-
- // Get 4 corner points in pixel coordinates
- float rotation(GetRegionState().rotation);
- casacore::Vector x, y;
- RectanglePointsToCorners(pixel_points, rotation, x, y);
-
- // Convert corners to wcs in one call for efficiency
- size_t num_points(x.size()), num_axes(_coord_sys->nPixelAxes());
- casacore::Matrix pixel_coords(num_axes, num_points);
- casacore::Matrix world_coords(num_axes, num_points);
- pixel_coords = 0.0;
- pixel_coords.row(0) = x;
- pixel_coords.row(1) = y;
- casacore::Vector failures;
- if (!_coord_sys->toWorldMany(world_coords, pixel_coords, failures)) {
- return false;
- }
-
- // Save x and y values as Quantities
- casacore::Vector world_units = _coord_sys->worldAxisUnits();
- casacore::Vector x_wcs = world_coords.row(0);
- casacore::Vector y_wcs = world_coords.row(1);
- // reference points: corners (x0, y0, x1, y1, x2, y2, x3, y3) in world coordinates
- wcs_points.resize(num_points * 2);
- for (int i = 0; i < num_points; ++i) {
- wcs_points[i * 2] = casacore::Quantity(x_wcs(i), world_units(0));
- wcs_points[(i * 2) + 1] = casacore::Quantity(y_wcs(i), world_units(1));
- }
- return true;
-}
-
-void Region::RectanglePointsToCorners(
- std::vector& pixel_points, float rotation, casacore::Vector& x, casacore::Vector& y) {
- // Convert rectangle control points to 4 corner points
- float center_x(pixel_points[0].x()), center_y(pixel_points[0].y());
- float width(pixel_points[1].x()), height(pixel_points[1].y());
- x.resize(4);
- y.resize(4);
-
- if (rotation == 0.0) {
- float x_min(center_x - width / 2.0f), x_max(center_x + width / 2.0f);
- float y_min(center_y - height / 2.0f), y_max(center_y + height / 2.0f);
- // Bottom left
- x(0) = x_min;
- y(0) = y_min;
- // Bottom right
- x(1) = x_max;
- y(1) = y_min;
- // Top right
- x(2) = x_max;
- y(2) = y_max;
- // Top left
- x(3) = x_min;
- y(3) = y_max;
- } else {
- // Apply rotation matrix to get width and height vectors in rotated basis
- float cos_x = cos(rotation * M_PI / 180.0f);
- float sin_x = sin(rotation * M_PI / 180.0f);
- float width_vector_x = cos_x * width;
- float width_vector_y = sin_x * width;
- float height_vector_x = -sin_x * height;
- float height_vector_y = cos_x * height;
-
- // Bottom left
- x(0) = center_x + (-width_vector_x - height_vector_x) / 2.0f;
- y(0) = center_y + (-width_vector_y - height_vector_y) / 2.0f;
- // Bottom right
- x(1) = center_x + (width_vector_x - height_vector_x) / 2.0f;
- y(1) = center_y + (width_vector_y - height_vector_y) / 2.0f;
- // Top right
- x(2) = center_x + (width_vector_x + height_vector_x) / 2.0f;
- y(2) = center_y + (width_vector_y + height_vector_y) / 2.0f;
- // Top left
- x(3) = center_x + (-width_vector_x + height_vector_x) / 2.0f;
- y(3) = center_y + (-width_vector_y + height_vector_y) / 2.0f;
- }
-}
-
-bool Region::EllipsePointsToWorld(
- std::vector& pixel_points, std::vector