-1

Since I have no experience in IDL coding, I need help converting the piece of code below to python.

The following parameters are known and are 1D arrays oder scalars.

IDefScaleSondNbScale, IDefScaleSondScaleFactor,
IDefScaleSondNsfirst, IDefScaleSondNslast,
IDefNsfirst

enter image description here

Kai Burghardt
  • 1,046
  • 1
  • 8
  • 23
Shaun
  • 461
  • 3
  • 5
  • 22
  • Um, that is not Matlab. Looks like Pascal. Guess you haven’t coded Matlab in a while :) – mhopeng Feb 19 '23 at 03:22
  • @mhopeng ha! thanks a lot :) I changed the title. – Shaun Feb 20 '23 at 13:58
  • 2
    @mhopeng No, Pascal uses `:=` as the assignment operator. `=` is the equality relational operator. Besides that, semicolons `;` are required to separate statements. – Kai Burghardt Feb 20 '23 at 20:40
  • 1
    @KaiBurghardt Any guess what it is then? The “For-To-Do” is rare in my experience. Maybe it’s just pseudo code. – mhopeng Feb 22 '23 at 06:00

1 Answers1

0

It's IDL and the python equivalent is the following:

SpectDecoded = np.empty_like(Spect, dtype=float)
for numScale in range(1, int(IDefScaleSondNbScale) + 1):
    SF = IDefScaleSondScaleFactor[numScale - 1]
    for chanNb in range(int(IDefScaleSondNsfirst[numScale - 1]), int(IDefScaleSondNslast[numScale - 1]) + 1):
        w = int(chanNb - IDefNsfirst[0])
        if w < SpectDecoded.shape[0]:
            SpectDecoded[w] = Spect[w] * 10 ** (-SF)
Shaun
  • 461
  • 3
  • 5
  • 22