<div dir="ltr">Great, thanks very much.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 4 Apr 2021 at 17:46, Oliver Jahn <<a href="mailto:jahn@mit.edu">jahn@mit.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">dtype='>f4'<br>
<br>
On 2021-04-04 10:21, Jeremy Miller wrote:<br>
> Dear Oliver,<br>
> <br>
> Thanks. That appears to have worked. The plots I got look similar to the<br>
> ones in the tutorial.<br>
> I ran Jeff Scott's code in the exact same form (but<br>
> with h.astype('>f4').tofile('bathy.bin')<br>
> and tau.astype('>f4').tofile('windx_cosy.bin') commented).<br>
> I still get a mismatch between the outputs from snippet tauMax*sin(Y*pi)<br>
> and np.fromfile('windx_siny.bin',dtype='f4').<br>
> Why is that?<br>
> <br>
> Best<br>
> <br>
> Jeremy <br>
> <br>
> On Sun, 4 Apr 2021 at 16:41, Oliver Jahn <<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a><br>
> <mailto:<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a>>> wrote:<br>
> <br>
> This<br>
> <br>
> [X,Y]=np.meshgrid(x,y,indexing='ij')<br>
> <br>
> should be<br>
> <br>
> [Y,X]=np.meshgrid(y,x,indexing='ij')<br>
> <br>
> (with indexing 'ij' it is y,x, with indexing 'xy' it is x,y)<br>
> <br>
> I am attaching the script from Jeff's pull request where this is all<br>
> done correctly.<br>
> <br>
> Oliver<br>
> <br>
> <br>
> On 2021-04-04 09:00, Jeremy Miller wrote:<br>
> > Dear Oliver,<br>
> ><br>
> > Thanks for coming back to me. I did just that. I now get a plot for<br>
> > "eta" that appears to be two sets of constant values, on the left and<br>
> > right of the line x=0.6*1e6 m (see the attached plot in<br>
> > fig_bar_gyre_windx_siny.png). I also notice that the output bin file<br>
> > (tau_2_1) still shows different values to the original numpy array<br>
> > (tau_2). I have attached the latest version of the python script<br>
> used to<br>
> > generate the data (<a href="http://gendata_tut4.1.py" rel="noreferrer" target="_blank">gendata_tut4.1.py</a> <<a href="http://gendata_tut4.1.py" rel="noreferrer" target="_blank">http://gendata_tut4.1.py</a>><br>
> <<a href="http://gendata_tut4.1.py" rel="noreferrer" target="_blank">http://gendata_tut4.1.py</a>>) and the<br>
> > script used to generate the plots (<a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">tut_4.1_plots.py</a><br>
> <<a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">http://tut_4.1_plots.py</a>><br>
> > <<a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">http://tut_4.1_plots.py</a>>).<br>
> ><br>
> > Best<br>
> > Jeremy<br>
> ><br>
> > On Sun, 4 Apr 2021 at 13:48, Oliver Jahn <<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a><br>
> <mailto:<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a>><br>
> > <mailto:<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a> <mailto:<a href="mailto:jahn@mit.edu" target="_blank">jahn@mit.edu</a>>>> wrote:<br>
> ><br>
> > Hi Jeremy,<br>
> ><br>
> > this will not work:<br>
> ><br>
> > > if sys.byteorder == 'little': tau_2.byteswap(True)<br>
> > > fid = open('windx_siny.bin', 'wb')<br>
> > > tau_2.astype('float32').tofile(fid)<br>
> ><br>
> > Can you instead try Jeff's suggestion:<br>
> ><br>
> > tau_2.astype('>f4').tofile('windx_siny.bin')<br>
> ><br>
> > and NOT use the byteswap command? Mixing byteswap and astype<br>
> is a bad<br>
> > idea as byteswap will create a mismatch between the data in<br>
> memory and<br>
> > numpy's assumption of the data type.<br>
> ><br>
> > Best,<br>
> > Oliver<br>
> ><br>
> ><br>
> > > as you suggested, the plot still came out blank.<br>
> > > Regarding Jeffrey Scott's comment that the reason I<br>
> could not read<br>
> > back<br>
> > > the bin file was due to a mismatch between float32 and<br>
> float64, I<br>
> > > followed his advice and read in the<br>
> > > bin file using the snippet <br>
> > ><br>
> > > tau_2_1 = np.fromfile('windx_siny.bin',dtype='float32')<br>
> > ><br>
> > > and I got back an array with every entry being 'inf' except the<br>
> > > penultimate column, being all '0'.<br>
> > ><br>
> > > Is it possible that the snippet <br>
> > ><br>
> > > # X=X.astype('float128')<br>
> > > # Y=Y.astype('float128')<br>
> > ><br>
> > > (which is commented) needs to be included but with<br>
> 'float128' replaced<br>
> > > with 'float32'?<br>
> > ><br>
> > > Best<br>
> > > Jeremy<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > On Thu, 1 Apr 2021 at 16:47, Jan Klaus Rieck<br>
> > <<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a> <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a>><br>
> <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a> <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a>>><br>
> > > <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a><br>
> <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a>><br>
> > <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a><br>
> <mailto:<a href="mailto:jan.rieck@mail.mcgill.ca" target="_blank">jan.rieck@mail.mcgill.ca</a>>>>> wrote:<br>
> > ><br>
> > > Hello Jeremy Miller,<br>
> > ><br>
> > > I also use python to to generate input data for the<br>
> MITgcm. I<br>
> > found<br>
> > > that, to generate files that can be read by the MITgcm<br>
> > consistently,<br>
> > > I needed to specify the type explicitly. <br>
> > > My way of saving the files would look like this in your<br>
> case: <br>
> > ><br>
> > > if sys.byteorder == 'little': tau_2.byteswap(True)<br>
> > > fid = open(''windx_siny.bin', 'wb')<br>
> > > tau_2.astype('float32').tofile(fid)<br>
> > ><br>
> > > Of course, 'float32' could be replaced by 'float64' if<br>
> you require<br>
> > > double precision.<br>
> > ><br>
> > > I hope this helps,<br>
> > > Jan Rieck<br>
> > > <br>
> > > On Thu, 2021-04-01 at 10:22 +0300, Jeremy Miller wrote:<br>
> > >> Dear MITGCM forum,<br>
> > >><br>
> > >> I am Jeremy Miller, I am new to MITgcm and I've been going<br>
> > through<br>
> > >> the tutorials. I have a question about the "Barotropic<br>
> Ocean<br>
> > Gyre"<br>
> > >> tutorial (section 4.1).<br>
> > >><br>
> > >> I managed to compile and run the code, and re-produce<br>
> the first<br>
> > >> two plots shown in section 4.1.5 for wind stress of τ<br>
> = τ0 cos(<br>
> > >> πy/Ly), for both the advection and non-advection cases<br>
> (with the<br>
> > >> provided input binary files). <br>
> > >> I ran into problems when trying to produce the third plot,<br>
> > for the<br>
> > >> case where τ = τ0 sin( πy/Ly). I am a python user, so I<br>
> > translated<br>
> > >> gendata.m into python to write the input binary<br>
> > >> files 'windx_cosy.bin' 'windx_siny.bin' (see the file<br>
> > >> gendata_tut4.1py attached). As explained in section<br>
> 3.9 I've<br>
> > >> included the snippet <br>
> > >><br>
> > >> if sys.byteorder == 'little': tau_2.byteswap(True)<br>
> > >><br>
> > >> where "tau2" is the array to be output. There was no<br>
> issue in the<br>
> > >> cosine wind stress, and I managed to reproduce the<br>
> results that I<br>
> > >> got with the original 'windx_cosy.bin' provided in the<br>
> tutorial.<br>
> > >> However, with the sine wind stress case, the output in<br>
> > >> 'Eta.0000077760.001.001' is all zeros. <br>
> > >><br>
> > >> When I attempt to read 'windx_siny.bin' with python<br>
> into a new<br>
> > >> array called tau2_1. I get absurdly big numbers back, which<br>
> > do not<br>
> > >> match the original array tau2 that I created. If I<br>
> Remove the<br>
> > >> snippet " if sys.byteorder == 'little':<br>
> tau_2.byteswap(True)<br>
> > ", in<br>
> > >> the python gendata code, tau2_1 and tau2 match. But,<br>
> then when I<br>
> > >> run the code again, the file output.txt contains a long<br>
> list<br>
> > of NaNs.<br>
> > >><br>
> > >> I have also included the python code used to generate the<br>
> > plots in<br>
> > >> the file <a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">tut_4.1_plots.py</a> <<a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">http://tut_4.1_plots.py</a>><br>
> <<a href="http://tut_4.1_plots.py" rel="noreferrer" target="_blank">http://tut_4.1_plots.py</a>><br>
> > <<a href="http://tut_4.1_plots.py/" rel="noreferrer" target="_blank">http://tut_4.1_plots.py/</a>><br>
> > >><br>
> > >> Look forward to hearing from you.<br>
> > >> Yours sincerely<br>
> > >> Jeremy Miller<br>
> > >> _______________________________________________<br>
> > >> MITgcm-support mailing list<br>
> > >> <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>><br>
> > >> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>><br>
> > <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>>><br>
> > >><br>
> > >> <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> > >><br>
> > > _______________________________________________<br>
> > > MITgcm-support mailing list<br>
> > > <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>><br>
> > <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>>><br>
> > > <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > MITgcm-support mailing list<br>
> > > <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>><br>
> > > <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> > ><br>
> > _______________________________________________<br>
> > MITgcm-support mailing list<br>
> > <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>><br>
> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>>><br>
> > <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > MITgcm-support mailing list<br>
> > <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>><br>
> > <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> ><br>
> _______________________________________________<br>
> MITgcm-support mailing list<br>
> <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a> <mailto:<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a>><br>
> <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> <br>
> <br>
> _______________________________________________<br>
> MITgcm-support mailing list<br>
> <a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
> <a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
> <br>
_______________________________________________<br>
MITgcm-support mailing list<br>
<a href="mailto:MITgcm-support@mitgcm.org" target="_blank">MITgcm-support@mitgcm.org</a><br>
<a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" rel="noreferrer" target="_blank">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</a><br>
</blockquote></div>