NREL / h5plexos

Convert PLEXOS solutions to HDF5 and query results from Python
Other
5 stars 1 forks source link

UnicodeEncodeError #9

Closed mohitjoshi1986 closed 4 years ago

mohitjoshi1986 commented 4 years ago

I am converting one PLEXOS output to H5 file and getting this error

Traceback (most recent call last): File "C:\Users\mjoshi\AppData\Local\Programs\Python\Python38-32\Scripts\h5plexos-script.py", line 11, in load_entry_point('h5plexos==0.4.2', 'console_scripts', 'h5plexos')() File "C:\Users\mjoshi\AppData\Roaming\Python\Python38\site-packages\h5plexos__main__.py", line 10, in main process_solution(solutionfile) File "C:\Users\mjoshi\AppData\Roaming\Python\Python38\site-packages\h5plexos\process\buildh5.py", line 119, in process_solution dset, dset_name, dset_idxs = create_object_dset( File "C:\Users\mjoshi\AppData\Roaming\Python\Python38\site-packages\h5plexos\process\metadata.py", line 51, in create_object_dset data = np.array(data, dtype=meta_dtype) UnicodeEncodeError: 'ascii' codec can't encode character '\u1ea3' in position 2: ordinal not in range(128)

Not sure what the problem is. Has anybody faced similar issue ?. This is PLEXOS 8.1 and the solution is not reporting MT.

@GordStephen @Sabre626 The solution file is at \nrelqnap02.nrel.gov\PLEXOS\Projects\Temporary if you would like to have a look.

GordStephen commented 4 years ago

My first guess would be that there's a special character in an object (generator, region, etc) name that can't be stored as plain ASCII in the HDF5 file. We don't have a good way of dealing with this right now - we could automatically remove or try to replace non-ASCII characters with an alternative, but then the names in the HDF5 file will be different from those in the PLEXOS database. The better option might be to store text in the HDF5 file as Unicode, at the cost of potential reduced compatibility with other non-h5py HDF5 libraries.

While less than ideal, my immediate recommendation would be to find the offending character in the original PLEXOS database and change it in the PLEXOS GUI?

mohitjoshi1986 commented 4 years ago

Thanks Gord. Yes there was a special character in the model. I have removed that and now it works.