# pclean config — ALMA IRC+10216 cube imaging (spw 25)
#
# Usage (SLURM):
#   pclean submit scripts/test_alma_pclean_v4.yaml
#   pclean submit scripts/test_alma_pclean_v4.yaml \
#       --workdir /zfs/data2/Workspace/nrao/tests/projs/cubeimaging/pclean_v4
#
# Usage (local, no SLURM):
#   python -m pclean --pconfig scripts/test_alma_pclean_v4.yaml
#
# With psrecord profiling:
#   cd /zfs/data2/Workspace/nrao/tests/projs/cubeimaging/pclean_v4 && trash *
#   pixi run -e forge psrecord \
#     --log  ~/Workspace/nvme/nrao/casa_dist/pclean/pclean/logs/test_alma_pclean_4.rec \
#     --include-children --include-io --include-cache --use-timestamp \
#     --include-dir /zfs/data2/Workspace/nrao/tests/projs/cubeimaging/pclean_v4 \
#     "python -m pclean \
#        --pconfig ~/Workspace/nvme/nrao/casa_dist/pclean/pclean/scripts/test_alma_pclean_v4.yaml \
#        --log-level DEBUG \
#        > ~/Workspace/nvme/nrao/casa_dist/pclean/pclean/logs/test_alma_pclean_4.log 2>&1"

# ── Data selection ────────────────────────────────────────────────
selection:
  vis:
    - /zfs/data0/Workspace/nrao/datasets/alma_if/cubeimaging/uid___A002_Xf0fd41_X5f5a_target.ms
  field:    IRC+10216
  spw:      ['25']
  antenna:  ['0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39&']
  scan:     ['7,9,11,13,15,17,19,20,24,26,28,30,32,34,36,37,41,43,45,47,49,51,53,54,58,60,62,64,66,68,70,71,75,77,79']
  intent:   OBSERVE_TARGET#ON_SOURCE
  datacolumn: data

# ── Image parameters ─────────────────────────────────────────────
image:
  imagename: pclean.IRC+10216_sci.spw25.cube.regcal.I
  imsize:    [128, 128]          # full-field: [8000, 8000]
  cell:      '0.0046arcsec'
  phasecenter: 'ICRS 09:47:57.460 +013.16.43.94'   # source center
  # phasecenter: 'ICRS 09:47:57.4981 +013.16.44.121'  # field phase center
  stokes:    I
  specmode:  cube
  nchan:     7677                 # sample cube: 1000 @ 268.5GHz
  start:     '267.5866469025GHz'  # alternatives: 268.676 GHz (90 ch)
  width:     '0.2441382MHz'
  outframe:  LSRK
  perchanweightdensity: true

# ── Gridding ─────────────────────────────────────────────────────
grid:
  gridder:     standard
  mosweight:   false
  usepointing: false
  pblimit:     0.2

# ── Weighting ────────────────────────────────────────────────────
weight:
  weighting: briggsbwtaper
  robust:    0.5
  npixels:   0

# ── Deconvolution / masking ──────────────────────────────────────
deconvolution:
  deconvolver:  hogbom
  restoration:  false
  pbcor:        false
  # restoringbeam: common
  usemask:            auto-multithresh
  sidelobethreshold:  2.5
  noisethreshold:     5.0
  lownoisethreshold:  1.5
  negativethreshold:  7.0
  minbeamfrac:        0.3
  growiterations:     50
  dogrowprune:        true
  minpercentchange:   1.0
  fastnoise:          true
  python_automask:    false

# ── Iteration control ────────────────────────────────────────────
iteration:
  niter:       0
  threshold:   '30mJy'          # per-plane RMS ≈ 14 mJy
  # threshold: '6.5mJy'         # deep clean
  # threshold: '2.0mJy'         # aggressive
  nsigma:      0.0
  interactive: false
  fullsummary: false

# ── Miscellaneous ────────────────────────────────────────────────
misc:
  savemodel: none

# ── Cluster / parallelism ────────────────────────────────────────
cluster:
  parallel:        true
  nworkers:        16
  cube_chunksize:  -1
  concat_mode:     paged
  keep_subcubes:   false
  type:            slurm

  slurm:
    queue:    queue
    job_mem:  2GB
    job_name: test_alma_pclean_v4
    python:   /zfs/nvme/Workspace/nrao/casa_dist/pclean/pclean/.pixi/envs/forge/bin/python

  submit:
    workdir:              /zfs/data2/Workspace/nrao/tests/projs/cubeimaging/pclean_slurm_v4
    pixi_project_dir:     /home/rxue/Workspace/nvme/nrao/casa_dist/pclean/pclean
    pixi_env:             forge
    coordinator_mem:      4G
    coordinator_cpus:     2
    coordinator_walltime: '24:00:00'
    coordinator_job_name: test_alma_pclean_v4-coordinator
    psrecord:             true    