CNES/swot_simulator

error messages in swath-generation jupyter while using Python module directly

Closed this issue · 6 comments

Hi,

I ran the Python Module to generate swath and while running these lines:

import swot_simulator.error.generator
error_generator = swot_simulator.error.generator.Generator(parameters, first_date)

I am getting error message like this:


TypeError Traceback (most recent call last)
/tmp/ipykernel_45/2918145375.py in
2
3
----> 4 error_generator = swot_simulator.error.generator.Generator(parameters, first_date)

TypeError: init() missing 1 required positional argument: 'orbit_duration'

I didn't face this issue when I was running a week before. But today I faced this. I don't know how to fix it.

Thanks.

In the new version under development, we have introduced the simulation of the orbital perturbation. For this, we need to pass the orbit duration to the simulated error generator. So, to use the generator directly, you have to write the following code:

import numpy
import swot_simulator.error
import swot_simulator.error.generator
import swot_simulator.orbit_propagator
import swot_simulator.settings

settings = swot_simulator.settings.Parameters.load_default()
settings.noise.pop(settings.noise.index('WetTroposphere'))
with open(settings.ephemeris) as stream:
    orbit = swot_simulator.orbit_propagator.calculate_orbit(settings, stream)

first_date = numpy.datetime64("now")

error_generator = swot_simulator.error.generator.Generator(
    settings, first_date, orbit.orbit_duration())

Thank you so much. This issue is fixed now but I am getting another error at the very end when I try to plot the output:
When I run these lines:

fig = matplotlib.pyplot.figure(figsize=(24, 12))
ax = fig.add_subplot(1, 1, 1, projection=cartopy.crs.PlateCarree())
contourf = ax.contourf(selected.longitude,
selected.latitude,
selected.ssh_karin,
transform=cartopy.crs.PlateCarree(),
levels=255,
cmap='jet')
fig.colorbar(contourf, orientation='vertical')
ax.set_extent([60, 69, -50, -40], crs=cartopy.crs.PlateCarree())
ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False)
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.COASTLINE)
ax.coastlines()

I am getting error message like this:


AttributeError Traceback (most recent call last)
/tmp/ipykernel_45/3871656973.py in
3 contourf = ax.contourf(selected.longitude,
4 selected.latitude,
----> 5 selected.ssh_karin,
6 transform=cartopy.crs.PlateCarree(),
7 levels=255,

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/core/common.py in getattr(self, name)
237 with suppress(KeyError):
238 return source[name]
--> 239 raise AttributeError(
240 "{!r} object has no attribute {!r}".format(type(self).name, name)
241 )

AttributeError: 'Dataset' object has no attribute 'ssh_karin'

I am not sure what to make of it. Did the initial dataset ds should have had any variable called "ssh" and it doesn't have it now? Would you suggest how I can resolve this issue?

I have updated the notebook on GitHub. See if this makes your problem disappear.

Thank you for updating the notebook. But no, the error message is the same at the end while plotting:

AttributeError: 'Dataset' object has no attribute 'ssh_karin'

Can you give me a copy of your notebook in a gist?

Thanks! it's working now.