OceanParcels / Parcels

Main code for Parcels (Probably A Really Computationally Efficient Lagrangian Simulator)
https://www.oceanparcels.org
MIT License
295 stars 136 forks source link

add_field bug when working with summed_fields #837

Closed claudiofgcardoso closed 4 years ago

claudiofgcardoso commented 4 years ago

Hello all,

When running the new version of Parcels (v2.2.0) I encountered the following error, resultant from the 'fieldset.add_field' function:

Traceback (most recent call last):

  File "<ipython-input-2-9ef56b7b0821>", line 71, in <module>
    chunksize=chunksize)

  File "/home/ccardoso/Cenas/Academico/OOM/CleanAtlantic/OceanParcels/My_scripts/CleanAtlantic_Madeira/Functions/MyParcels_fieldset.py", line 132, in get_roms
    fieldset_final.add_field(taux)

  File "/home/ccardoso/anaconda3/lib/python3.7/site-packages/parcels/fieldset.py", line 151, in add_field
    if fld.grid == g_set:

AttributeError: 'SummedField' object has no attribute 'grid'

As the message suggests, this new grid verification to "avoid re-processing/overwriting existing and working fields" does not account for the usage of Summed_Fields... Editing the if statement in line 151 to:

if isinstance(fld, Field) and fld.grid == g_set:

solves the error, but is only a quick fix because the verification is still not dealt with appropriately.

Cheers, Cláudio

erikvansebille commented 4 years ago

Thanks for reporting, @claudiofgcardoso. I have just pushed a solution in #838. Can you check if this works for you?

claudiofgcardoso commented 4 years ago

Thanks for the quick reply! Checked and works perfectly.