Closed shyamrnjn closed 7 years ago
This LineString
error is very strange, I have never seen it before. Can you give me a little more information:
In part 1:
Are you sure that you have the appropriate data for the time/location for which you are generating trajectories? (Just have to make sure!) Also, check that pysplit.make_trajectorygroup()
is pointing to the right place.
What is the basename
you use in pysplit.generate_trajectories()
?
Can you give me the first 15 or so lines of a trajectory file that should end up in trajgroup
? I'd like to see if there is anything weird going on with your trajectories.
In part 2, where you're running trajgroup = pysplit.make_trajectorygroup(r'C:/trajectories/jnushyam/aug*')
:
What do you get when run print(trajgroup.trajcount)
?
Is anything at all- either an empty figure or a figure with a map- displaying when you run this code?
Do you have the %matplotlib inline
magic in one of your jupyter notebook's cells?
What happens if you try bmap.ax.get_figure()
in a new cell?
Thanks!
Hi, In part 1:
I have downloaded the GDAS data in ARL formal for trajectory generation
jnushyam
is my basename
,
basename = 'jnushyam'
In part 2:
running print(trajgroup.trajcount
gives me 0 value
I have not used the %matplotlib inline
magic i my jupyter cell
running bmap.ax.get_figure()
give me an empty figure with only coordinates on x and y axis.
Here is the following codes which i used to generate trajectories;
import pysplit
working_dir = r'C:/hysplit4/working' storage_dir = r'C:/trajectories/jnushyam' meteo_dir = r'H:/hysplit/gdas'
basename = 'jnushyam'
years = [2016] months = [2,6,8,11] hours = [11, 17, 23] altitudes = [500, 1000, 1500] location = (28.70, 77.14) runtime = -120 monthslice=slice(0, 32, 2)
pysplit.generate_bulktraj(basename, working_dir, storage_dir, meteo_dir, years, months, hours, altitudes, location, runtime, monthslice)
trajgroup = pysplit.make_trajectorygroup(r'C:/trajectories/jnushyam/aug*')
`mapcorners = [40, -15, 170, 60]
standard_pm = None`
bmap_params = pysplit.MapDesign(mapcorners, standard_pm)
bmap = bmap_params.make_basemap()
`color_dict = {500.0 : 'blue',
1000.0 : 'orange',
1500.0 : 'black'}`
`for traj in trajgroup:
altitude0 = traj.data.geometry.apply(lambda p: p.z)[0]
traj.trajcolor = color_dict[altitude0]`
`for traj in trajgroup[::5]:
bmap.plot(*traj.path.xy, c=traj.trajcolor, latlon=True, zorder=20)`
print(trajgroup.trajcount)
bmap.ax.get_figure()
Its realy great that you have created this wondeerful plugins to help open source supporters like me. It would be great if you have some spare time solve this issues.
With Best
shyam
I opened up a few of your trajectory files and finally found the problem! During trajectory generation, PySPLIT
did not find all of the meteorology files it needed. This is the header in your files:
5 1
GDAS 16 7 22 0 0
GDAS 16 7 29 0 0
GDAS 16 8 1 0 0
GDAS 16 8 29 0 0
GDAS 16 9 1 0 0
1 BACKWARD OMEGA
16 8 7 23 28.700 77.140 500.0
1 PRESSURE
Notice it goes from GDAS 16 8 1 0 0
to GDAS 16 8 29 0 0
- in August, you're missing weeks 2, 3, and 4 of your meteorology (which if found would be listed in your header as GDAS 16 8 8 0 0
, GDAS 16 8 15 0 0
, and GDAS 16 8 22 0 0
). In trajectory files belonging to those weeks, there is absolutely nothing beyond this header- no data to read in means no Trajectory
. Your trajectory files that do have path information that can be read properly, but the data-less trajectory files cutoff the TrajectoryGroup
formation before those are reached.
So, check that you have those meteorology files and that their names follow the same pattern as the others, then try generating your trajectories again. I'll try to find a way to alert users of missing meteorology and hopefully prevent others from experiencing this issue.
Good luck! Let me know if you have any other issues! -Mellissa
Hi..
Thanks a lot for your informationa but after updating pysplit i have got another issues using this code (trajgroup = pysplit.make_trajectorygroup('C:/trajectories/jnushyam/aug') .
AttributeError Traceback (most recent call last) C:\Users\Shyam\Anaconda3\lib\site-packages\shapely\geometry\linestring.py in geos_linestring_from_py(ob, update_geom, update_ndim) 199 # From array protocol --> 200 array = ob.array_interface 201 assert len(array['shape']) == 2
AttributeError: 'list' object has no attribute 'array_interface'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last) in () ----> 1 trajgroup = pysplit.make_trajectorygroup('C:/trajectories/jnushyam/aug')
C:\Users\Shyam\Anaconda3\lib\site-packages\pysplit\hy_processor.py in make_trajectorygroup(signature) 74 trajectories.append(Trajectory(data, path, datetime, head, 75 folder, hyfile, clipdir, ---> 76 multitraj)) 77 78 # initialize trajectory group
C:\Users\Shyam\Anaconda3\lib\site-packages\pysplit\traj.py in init(self, trajdata, pathdata, datetime, trajheader, folder, filename, cfolder, multitraj) 52 If True, is from a file containing multiple trajectories 53 """ ---> 54 HyPath.init(self, trajdata, pathdata, datetime, trajheader) 55 56 self.data.rename(columns={'AIR_TEMP': 'Temperature',
C:\Users\Shyam\Anaconda3\lib\site-packages\pysplit\hypath.py in init(self, alongpath, pathdata, datetime, header) 37 columns=header[1:], geometry=pts) 38 ---> 39 self.path = LineString(pts) 40 41 self.data['DateTime'] = datetime
C:\Users\Shyam\Anaconda3\lib\site-packages\shapely\geometry\linestring.py in init(self, coordinates) 47 BaseGeometry.init(self) 48 if coordinates is not None: ---> 49 self._set_coords(coordinates) 50 51 @property
C:\Users\Shyam\Anaconda3\lib\site-packages\shapely\geometry\linestring.py in _set_coords(self, coordinates) 92 def _set_coords(self, coordinates): 93 self.empty() ---> 94 self._geom, self._ndim = geos_linestring_from_py(coordinates) 95 96 coords = property(BaseGeometry._get_coords, _set_coords)
C:\Users\Shyam\Anaconda3\lib\site-packages\shapely\geometry\linestring.py in geos_linestring_from_py(ob, update_geom, update_ndim) 256 if m < 2: 257 raise ValueError( --> 258 "LineStrings must have at least 2 coordinate tuples") 259 260 def _coords(o):
ValueError: LineStrings must have at least 2 coordinate tuples
Interestingly, if I use to remove the fromaug (i.e aug) (trajgroup = pysplit.make_trajectorygroup('C:/trajectories/jnushyam/aug*') then thiis command shows no error but executing the next commands don't display the trajectory map. To generate the traj map , I used the follwing commands to display the map with trajectory at jupyter notebook on window 10.
years = [2016] months = [2,6,8,11] hours = [11, 17, 23] altitudes = [500, 1000, 1500] location = (28.70, 77.14) runtime = -120 monthslice=slice(0, 32, 2)
pysplit.generate_bulktraj(basename, working_dir, storage_dir, meteo_dir, years, months, hours, altitudes, location, runtime, monthslice)
trajgroup = pysplit.make_trajectorygroup(r'C:/trajectories/jnushyam/aug*')
`mapcorners = [40, -15, 170, 60]
standard_pm = None`
bmap_params = pysplit.MapDesign(mapcorners, standard_pm)
bmap = bmap_params.make_basemap()
`color_dict = {500.0 : 'blue',
`for traj in trajgroup:
`for traj in trajgroup[::5]:
Thanks shyam-aug-2016.zip