[Python] Python code for creating images of .img radar files failing after specific point?

Discussão em 'Python' iniciado por Stack, Junho 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python code which takes the .lbl and .img of radar sounding data and produces a radargram, first of the full dataset and then clipped to within certain latitudes. For some reason the program is working for all files before a certain point, but then afterwards will ONLY produce the full radargram, and the clipped one is blank. I'm having a hard time understanding what the problem is, as the only difference is in the extent of the plot (i.e. ax.set_xlim and ax.set_ylim). I have tried restarting my computer, emptying the saved plots, and nothing seems to work. The files are not corrupted, and it is always the same files that work and don't work. Any ideas?

    The script for the full radargram:

    fig, ax = plt.subplots(figsize=(15,4))
    img = ax.imshow(image_db, cmap="gray", aspect="auto")
    ax.set_xlabel("Samples")
    ax.set_ylabel("Lines")
    ax.set_title("Radargram of "+filename)
    fig.colorbar(img, ax=ax, label="Echo Power (dB)")
    plt.savefig(r"path"+filename+".png", dpi=600)
    plt.show()
    plt.close()
    print("Saved full image.")


    The script for the clipped radargram:

    fig, ax = plt.subplots(figsize=(15,4))
    img = ax.imshow(image_db, cmap="gray", aspect="auto")
    ax.set_xlabel("Samples")
    ax.set_ylabel("Lines")
    ax.set_title("Radargram of "+filename)
    ax.set_xlim(xmin=first_index, xmax=last_index)
    ax.set_ylim(ymin=500, ymax=0)
    fig.colorbar(img, ax=ax, label="Echo Power (dB)")
    plt.savefig(r"path"+filename+"_clippedtoSP.png", dpi=600)
    plt.show()
    plt.close()
    print("Saved clipped image.")


    I know that first_index and last_index are correctly extracted, literally the only issue is that the plot is coming out blank.

    Continue reading...

Compartilhe esta Página