I wrote a new He I D3 script, now that I understand a bit better the quirks of the scripting.


 

# Script to create a pleasing He I D3 Sun, 
#    from enhancing the weak signal of helium
#    by applying continuum subtraction etc.
# The author fo this script checked these results
#    against the He I 10830 raw reconstructions, 
#    noting that even imaging, with a CMOS, at 1100nm
#    is rather challenging, and the match between 
#    this He I D3 concept, and the raw reconstruction 
#    of He I 10830 was found to be decent.
#
# Adjust the values below
#    The distance between Na I D2 and He I D3, 
#    in a SHG700, at 2um pixel size, is about -142.8
#    Pure coincidence, this is also the distance,
#    in a stock Sol'Ex, between Fe I 5884 and 
#    He I D3, at 2um pixel size

He_offset_px = -142.8
kontinuum_ofHe_offset_px = He_offset_px + 9

# For most spectroheliographs, the values below
#    need no adjustment

He_context_px = 1
He_step_px = 1

kontinuum_ofHe_context_px = 4
kontinuum_ofHe_step_px = 1

kontL = kontinuum_ofHe_offset_px - kontinuum_ofHe_context_px
kontR = kontinuum_ofHe_offset_px + kontinuum_ofHe_context_px

HeL = He_offset_px - He_context_px
HeR = He_offset_px + He_context_px

fixBanding1 = 100
fixBanding2 = 50

lineZero = min(autocrop2(range(-1, 1)))
lineZeroB = fix_banding(lineZero, fixBanding1, fixBanding2)
lineZeroBL = linear_stretch(lineZeroB)
lineZeroL = linear_stretch(lineZero)
lineZeroBLSQ = linear_stretch(pow(lineZeroB, 2))



HeRaw1 = min(autocrop2(range(HeL,HeR,He_step_px)))
HeProm1 = max(autocrop2(range(HeL-1,HeR+1,He_step_px)))
kontinuum_ofHe = avg(autocrop2(range(kontL,kontR, kontinuum_ofHe_step_px)))

n2 = 16
lineDisk_p0_VeryBlur1 = rescale_rel(blur(blur(blur(blur(blur(blur(blur(blur(rescale_rel(disk_mask(kontinuum_ofHe), 1/n2, 1/n2))))))))), n2, n2)

lineDisk_p0_VeryBlur2 = rescale_rel(blur(blur(blur(blur(blur(blur(blur(blur(rescale_rel(lineDisk_p0_VeryBlur1, 1/n2, 1/n2))))))))), n2, n2)

lineDisk_p0_VeryBlur3 = rescale_rel(blur(blur(blur(blur(blur(blur(blur(blur(rescale_rel(lineDisk_p0_VeryBlur2, 1/n2, 1/n2))))))))), n2, n2)

lineDisk_p0_VeryBlur4 = rescale_rel(blur(blur(blur(blur(blur(blur(blur(blur(rescale_rel(lineDisk_p0_VeryBlur3, 1/n2, 1/n2))))))))), n2, n2)




# to attenuate noise at recording edge,
#    far off from the disk, 
#    which would throw off 
#    the linear stretch
multi_p0_WithDisk = linear_stretch((pow(lineDisk_p0_VeryBlur4, 0.2)))

deltaHe2 = fix_banding(HeRaw1 - kontinuum_ofHe, fixBanding1, fixBanding2)
divida = fix_banding(multi_p0_WithDisk*(HeProm1 / kontinuum_ofHe),  fixBanding1, fixBanding2)


HeLog = pow(log(log(HeRaw1, 2), 2), 8)

dividaBlur = blur(blur(blur(blur(blur(divida)))))
dividaBlurM = dividaBlur*log(blur(blur(HeProm1)),2)  - pow(multi_p0_WithDisk, 1.2)


deltaHe2Blur = blur(blur(blur(deltaHe2)))

HeLogMulDelta1 = multi_p0_WithDisk*(HeLog * pow(deltaHe2Blur, 4))


masterOutput =  multi_p0_WithDisk* (
  HeRaw1
  +20  * linear_stretch(HeRaw1)
   +25  * linear_stretch(pow(deltaHe2*HeRaw1, 2))
   -6  * linear_stretch(kontinuum_ofHe)
   -6  * linear_stretch(pow(kontinuum_ofHe, 1/2))
   -6  * linear_stretch(multi_p0_WithDisk)   
   +1  * linear_stretch(pow(HeRaw1, 3))
 +150  * linear_stretch(HeRaw1*pow(deltaHe2Blur, 3))
  +25  * linear_stretch(HeRaw1*pow(deltaHe2Blur, 2))
  +20  * linear_stretch(HeRaw1*HeLogMulDelta1)
 +100  * linear_stretch(HeLogMulDelta1)
 +110  * linear_stretch(dividaBlurM)
)


dividaRot = rotate_rad(linear_stretch(divida), angleP)
HeRawLog = HeLog
HeLogMulDelta = HeLogMulDelta1
maskRot = rotate_rad(linear_stretch(multi_p0_WithDisk), angleP)
dividaBlurM1 = linear_stretch(dividaBlurM)


[outputs]

HeRawRot = rotate_rad(linear_stretch(HeRaw1), angleP)
kontinuumOfHeRot = rotate_rad(linear_stretch(kontinuum_ofHe), angleP)
deltaHe2Rot = rotate_rad(linear_stretch(deltaHe2), angleP)
HeSomething3 = rotate_rad(linear_stretch(masterOutput), angleP)