kvos / CoastSat

Global shoreline mapping tool from satellite imagery
http://coastsat.space
GNU General Public License v3.0
696 stars 252 forks source link

Tidal correction bug in example.py #498

Closed lexterspiritus97 closed 5 months ago

lexterspiritus97 commented 5 months ago

Hi everybody. I recently reinstalled the Conda software, the Anaconda navigator and installed the CoastSat2.5. I started to run the Narrabeen example, for december 2017, because in this period there is tidal data in the example. Everything went well, OK, until I reached the tidal correction batch. The software seems to calculate the This section raised this TypeError exception:

runcell('4. Tidal correction', 'D:/SoftwarePython_CoastSat_V5/CoastSat-2.5/example.py') Extracting closest points: 100%Traceback (most recent call last): File ~\anaconda3\envs\coastsat\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec exec(code, globals, locals) File d:\softwarepython_coastsat_v5\coastsat-2.5\example.py:267 ax.plot(dates_sat, tides_sat, '-o', color='k', ms=6, mfc='w',lw=1, label='image acquisition') File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\axes_axes.py:1724 in plot lines = [self._get_lines(self, args, data=data, *kwargs)] File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\axes_base.py:303 in call yield from self._plot_args( File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\axes_base.py:494 in _plot_args axes.xaxis.update_units(x) File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\axis.py:1717 in update_units self._update_axisinfo() File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\axis.py:1729 in _update_axisinfo info = self.converter.axisinfo(self.units, self) File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\dates.py:1882 in axisinfo return self._get_converter().axisinfo(args, **kwargs) File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\dates.py:1799 in axisinfo majloc = AutoDateLocator(tz=tz, File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\dates.py:1333 in init super().init(tz=tz) File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\dates.py:1132 in init self.tz = _get_tzinfo(tz) File ~\anaconda3\envs\coastsat\Lib\site-packages\matplotlib\dates.py:236 in _get_tzinfo raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.") TypeError: tz must be string or tzinfo subclass, not <matplotlib.category.UnitData object at 0x0000019262051250>.

I'm novel using Python, So, I dont get it. I understand that the problem is using matplotlib, when trying to extract closest points between tide and image date. Can anyone helpme please??? Give any idea how to solve this. Thanks a lot in advance. Lexter.

kvos commented 5 months ago

hi Lexter, yes happy to help. Can you post some screenshots of the cell you're trying to run and your settings so we can troubleshoot what may be going on. It seems like an easy fix, something with the way timezones are defined in the csv file with the tide data.

lexterspiritus97 commented 5 months ago

Hi Kilian. Here I post the screenshots of the cells I'm running, as a version of your example for Narrabeen:

From the cell 1: #%% 1. Initial settings Batch1 It runs OK

Cell 3: #%% 3. Batch shoreline detection Batch3 It runs OK

Cell 5: Batch5 Batch5_2 Here is the problem!! For you to see, the original csv file with the tidal data and the ouput figure of the coastsat: Tides_csv_and_resultsFigure Can you see the screenshots figures? Thankyou, Lexter.

kvos commented 5 months ago

thanks, I was able to replicate the error, will fix it and let you know when it is done.

kvos commented 5 months ago

it was a silly one, matplotlib was trying to plot the dates as strings instead of datetime objects, I just had to replace line 266 of example.py as shown below (you can probably do it on your script directly instead of pulling the changes with github. image The figure now looks good. Figure_4

lexterspiritus97 commented 5 months ago

Ouu, great!! It works now!!! Thankyou, merci beaucoup. gracias. It is already fixed with what you suggested. I need to ask you something else. I tried to apply CoastSat for a beach in the caribean sea, specifically in the south coast of Cuba. But after I ran the first 3 batches the preprocessed images are pixelated. So have not the quality needed to map the shorelines. Why could it be happening? 2023-09-22-16-07-13_S2 Thank a lot in advance Lexter

kvos commented 5 months ago

that's 10 m resolution mate!

lexterspiritus97 commented 5 months ago

Ok I see. But how can I change that? I have been looking for in the python script, but I haven't found any line which controls that resolution. Where do I change this? And wich is the correct or conveniente resolution? Give me some idea please. Thankyou so much Lester

kvos commented 5 months ago

you cannot change the resolution. you could however use a different satellite like the 3m/pixel Planet imagery, see this toolbox (https://github.com/ydoherty/CoastSat.PlanetScope). I will close this issue for the time being.

lexterspiritus97 commented 5 months ago

Uuffff!!, Well let´s continue with the others things. I will check the toolbox you suggest. Ok thankyou.