Skip to content

Commit

Permalink
mode project orth basis
Browse files Browse the repository at this point in the history
  • Loading branch information
oguyon committed Aug 14, 2024
1 parent 53e6db4 commit eb69098
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions plugins/milk-extra-src/linalgebra/scripts/milk-modes-project-U
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

MSdescr="Linear projection of modesA onto modesB"

MSextdescr="Project modesA (image cube) onto modesB (image cube)
modesB assumed to be orthogonal basis
Main steps:
- Decompose modesA according to basis B (decomposition coefficients are mcoeff)
- Use mcoeff and basis B to reconstruct projection of modesA onto modesB
- Compute the residual of the reconstruction = modesA - reconstruction
Output:
- projection
- reconstruction
"

source milk-script-std-config

RequiredCommands=( milk-all )
RequiredFiles=()
RequiredDirs=()


MSarg+=( "inmodesA:string:input modes to be decomposed" )
MSarg+=( "inmodesB:string:modes onto which to decompose" )
MSarg+=( "SVDlim:float:SVD limit" )
MSarg+=( "outimrec:string:reconstruction (projection)" )
MSarg+=( "outimres:string:residual" )

GPUindex="-1"
MSopt+=( "g:gpu:setgpu:GPU[int]:GPU index, -1 for CPU" )
function setgpu() {
GPUindex="$1"
}


source milk-argparse


immA="${inputMSargARRAY[0]}"
immB="${inputMSargARRAY[1]}"
svdlim="${inputMSargARRAY[2]}"
outimrec="${inputMSargARRAY[3]}"
outimres="${inputMSargARRAY[4]}"

milk-all << EOF
loadfits "$immA" modesA
loadfits "$immB" modesB
linalg.sgemm .GPUdevice ${GPUindex}
linalg.sgemm .transpA 1
linalg.sgemm modesA modesB mcoeff
linalg.sgemm .transpA 0
linalg.sgemm .transpB 1
linalg.sgemm svdU mcoeff imrec
saveFITS imrec "$outimrec"
imres=modesA-imrec
saveFITS imres "$outimres"
exitCLI
EOF


0 comments on commit eb69098

Please sign in to comment.