-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regarding custom classes and the issue of outputting to an NC file #1388
Comments
Hi,
In your update() you are calling super().update(). I have never seen this being done before, but it might work well in this case. You call a method self.delete_element(), is this something you have defined elsewhere? It is important to use the built in self.deactivate_elements() for the internal bookeeping to be correct. |
Thank you for your prompt response, and I apologize if my previous message was overly detailed. My primary question concerns whether OpenDrift can track additional attributes of particles during drift simulations, such as cumulative environmental factors like temperature and salinity. Additionally, is it possible to output these results directly into a NetCDF file? Could you provide some guidance on how to ensure that custom particle attributes like accumulated temperature are correctly saved in the NetCDF output? I am particularly interested in whether additional steps or configurations are required to include these custom variables in the output file. Best regards |
All element properties are saved automatically (and saved to netCDF if outfile is specified for stimulation), so you only need to add/define the properties (as you already did) and then also update these within the update method. |
Thanks. I understand now that the properties should indeed be saved automatically to the NetCDF file if defined and updated correctly within the update method. I will run another test to ensure that this functionality works as expected, as my previous attempts did not successfully save the custom element properties to the NetCDF file. |
Looking again at your code, it seems that you are defining a new class, but you are not using this one, but instead OceanDrift. |
Hello,
I am conducting a test simulation for surface fish egg dispersion using OpenDrift with ROMS data, which is accessible and readable. Basic tests run smoothly, but I’m encountering some issues in my test where I implemented a more complex simulation.
I have customized a particle class named CustomElement, which inherits from LagrangianArray. This class includes several custom variables such as age, accumulated temperature, distance, previous coordinates (latitude and longitude), and a flag for successful hatching. Furthermore, I created a custom drift model CustomDriftModel that inherits from OceanDrift and overrode the update method to manage particle states. Each timestep updates the particle’s age, accumulated temperature, and distance traveled, and checks whether the particles exceed 30 days or reach a specified hatching temperature threshold, deleting or updating particle states accordingly.
My objective is twofold:
1. Developmental Temperature Check: At the time of particle release, I need to check if the water temperature meets a specific threshold, which is the developmental temperature necessary for the initial survival or development of the eggs.
2. Accumulated Temperature Over Time: As the particles drift, I aim to calculate whether the accumulated temperature—measured as the sum of temperature excess over a base value during the drift—reaches a certain threshold within a specified timestep. This accumulated temperature represents the necessary heat units for the development of the eggs.
The aim is to simulate the developmental threshold temperature and the effective accumulated temperature processes for particle development. While the simulation runs, I am unable to save these custom particle states to the resulting NetCDF file.
Could this issue be related to how I’ve defined my custom classes? Any guidance or suggestions would be greatly appreciated.
test.txt
Thank you.
The text was updated successfully, but these errors were encountered: