Hi,
I've been several days with this not quite getting what I need. Any help would be much appreciated.
I'm trying to use python to shift the longitude values of a netcdf file. The original file longitude goes from -1.875 to +360
I need the file to show properly when importing it in Arcmap (Make NetCDF Raster Layer) so the raster and its values are -180 180 (as well as -90 90). The values are vertical velocity depth.
I'm trying a short script that someone showed online with a similar issue. Apparently it worked for him. In my case I just manage to shift the frame but not the values (see picture).

Any suggestions? Many thanks
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
<SPAN class="keyword token">import</SPAN> netCDF4
<SPAN class="keyword token">from</SPAN> netCDF4 <SPAN class="keyword token">import</SPAN> Dataset
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN>
<SPAN class="keyword token">from</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>sa <SPAN class="keyword token">import</SPAN><SPAN class="operator token">*</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckOutExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Spatial"</SPAN><SPAN class="punctuation token">)</SPAN>
Bathy <SPAN class="operator token">=</SPAN> Dataset<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"H:\NETcdf_TEST\tdhteo.pfclapr.nc"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'r+'</SPAN><SPAN class="punctuation token">,</SPAN> format<SPAN class="operator token">=</SPAN><SPAN class="string token">"NETCDF4"</SPAN><SPAN class="punctuation token">)</SPAN>
lon <SPAN class="operator token">=</SPAN> Bathy<SPAN class="punctuation token">.</SPAN>variables<SPAN class="punctuation token">[</SPAN>u<SPAN class="string token">'longitude'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN>
lat <SPAN class="operator token">=</SPAN> Bathy<SPAN class="punctuation token">.</SPAN>variables<SPAN class="punctuation token">[</SPAN>u<SPAN class="string token">'latitude'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN>
depth <SPAN class="operator token">=</SPAN> Bathy<SPAN class="punctuation token">.</SPAN>variables<SPAN class="punctuation token">[</SPAN>u<SPAN class="string token">'W_mm_dpth'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN>
depth_new <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>roll<SPAN class="punctuation token">(</SPAN>depth<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">360</SPAN><SPAN class="punctuation token">,</SPAN> axis <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
lon_new <SPAN class="operator token">=</SPAN> lon<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">178.125</SPAN>
Bathy<SPAN class="punctuation token">.</SPAN>variables<SPAN class="punctuation token">[</SPAN>u<SPAN class="string token">'longitude'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> lon_new
Bathy<SPAN class="punctuation token">.</SPAN>variables<SPAN class="punctuation token">[</SPAN>u<SPAN class="string token">'W_mm_dpth'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> depth_new
Bathy<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>