# Error: Plot latitude grid should be the same

**URL:** https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185
**Category:** VISAN
**Created:** [July 17, 2020, 2:01pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185 "2020-07-17T14:01:31Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 17, 2020, 2:01pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/1 "2020-07-17T14:01:31Z")

</div>

Dear,  
I’m developing a python script in order to obtain a 7 days average of NO2 values from Sentinel 5p and then dinamically visualize the change over a period of time (5 months). So I merge this 7 days average results keeping the time variable.

It works (apparently) but when I try to visualize the result into VISAN using wplot(product), I get this error:  
ValueError: plot latitudeGrid should be the same for all grids

What’s strange is that depending of the products I merge, I don’t get this error.

Could someone help me?

Thanks in advance,

Josep

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [July 17, 2020, 2:18pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/2 "2020-07-17T14:18:03Z")

</div>

You probably need to explain a bit more what you are doing exactly to generate your ‘product’ variable.  
The error you are getting happens if your latitude axis variable is 2 dimensional (time,latitude) and the latitude grid is not the same for different times.  
It is recommended to perform a `squash(time,(latitude,longitude))` as a final operation to remove the time dimension of your lat/lon axis variables.

---

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 17, 2020, 2:37pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/3 "2020-07-17T14:37:35Z")

</div>

Dear Sander,

first of all I import the products into harp in that way:

product\_name = harp.import\_product(base\_file + ext,  
operations=“latitude \> -55 [degree\_north]; latitude \< 60 [degree\_north]; tropospheric\_NO2\_column\_number\_density\_validity \> 75;bin\_spatial(271,-55,0.5,721,-180,0.5)”,  
post\_operations=“bin();squash(time, (latitude,longitude))”)

This happens inside a loop, and the variable product\_name change every time.

The products from one week are stored into a list. And when the list is filled with 7 products, I merge them using:

product\_bin = harp.execute\_operations(products, “”, “bin()”)

And then I export the result of this merge into a NetCDF file.  
harp.export\_product(product\_bin, str(nombre\_nc)+".nc")

Finally, I merge the products from several weeks using the command line:

harpmerge week\*.nc mosaic.nc

My idea is to visualize the evolution of the weekly NO average.

Thanks for your help.

Josep,

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [July 20, 2020, 7:50am UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/4 "2020-07-20T07:50:14Z")

</div>

Try using:

`harpmerge -ap 'squash(time,(latitude,longitude))' week*.nc mosaic.nc`

---

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 20, 2020, 8:02am UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/5 "2020-07-20T08:02:55Z")

</div>

Dear @svniemeijer,  
thanks for your reply.

But if I execute this harpmerge command, I get this error:

ERROR: variable ‘latitude’ does not exist

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [July 20, 2020, 8:18am UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/6 "2020-07-20T08:18:03Z")

</div>

Then what you have described above is not what you are actually doing.  
You should still have latitude and longitude variables.

---

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 20, 2020, 12:11pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/7 "2020-07-20T12:11:57Z")

</div>

Thanks @svniemeijer,  
I’ve made some changes, but now I get this error:  
ERROR: variable ‘latitude’ does not have the same values in each subdimension block for squash operation

Do you know what can happen?

Thanks!

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [July 20, 2020, 12:29pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/8 "2020-07-20T12:29:23Z")

</div>

You probably did not create all files using the same `bin_spatial()` configuration.  
You can’t mix grids with different lat/lon grids.

---

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 20, 2020, 12:31pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/9 "2020-07-20T12:31:13Z")

</div>

Hi @svniemeijer,  
I used the same bin\_spatial()  
I don’t know what is the reason of this error.

---

<div class="post-metadata">

### Author: ![josepsitjar](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@josepsitjar](https://forum.atmospherictoolbox.org/u/josepsitjar)
#### Post date: [July 20, 2020, 3:09pm UTC](https://forum.atmospherictoolbox.org/t/error-plot-latitude-grid-should-be-the-same/185/10 "2020-07-20T15:09:32Z")

</div>

Working with products from european region, do you think a bin\_spatial like that is correct?

bin\_spatial(271,-55,0.5,721,-180,0.5)

Thanks @svniemeijer
