mathewbarlow / simple-atmospheric-models

code for simple models of the atmosphere and ocean
29 stars 8 forks source link

Output data from linearized barotropic routine #1

Open AndrewILWilliams opened 2 years ago

AndrewILWilliams commented 2 years ago

Hi Matthew!

Just trying out your lbve_sbr_1.0.f routine, and I can get it to run and it outputs forecast.dat and summary.dat.

I can open these files in python with:

import numpy as np

np.fromfile("forecast.dat")

and I get a 1d vector of output (of length ntime*nlat*nlon, in some order...).

I was just wondering how to reshape this 1d output into something sensible and plot it in python? I'm a bit new to fortran so it's a bit confusing to me. My goal is to reproduce your excellent gif of Rossby waves propagating from the tropical Pacific into the extratropics. :)

Cheers, and enjoy Christmas! Andrew

mathewbarlow commented 2 years ago

Hi Andrew,

I'm about to sign off for the break but in case this helps quickly, I think what would work on my system is something like

nt = 504 nx = 128 ny = 64 forecast_1d = np.fromfile("forecast.dat", dtype='float32') forecast = np.reshape(forecast_1d, (nt, ny, nx))

plot last time

plt.contour(forecast[-1, :, :])

although I'm not sure off the top of my head if that's the right nt. Since it's a binary file, there may also be endian issues depending on what your os is (data was written on a mac).

If you're still stuck when I get back online after the holiday, I'll whip up a quick python program to plot it.

Happy Holidays! Matt

AndrewILWilliams commented 2 years ago

Thanks Matt, I'll give this a go soon.

Enjoy the time off :)

A