UWGlaciology / CommunityFirnModel

The repository for the Community Firn Model
MIT License
34 stars 20 forks source link

Reader/csv issues #7

Open GHOpenonic opened 2 years ago

GHOpenonic commented 2 years ago

Hello, I was trying to run the CFM using csv input files and got the error: "ValueError: could not convert string to float: '1980.00'" I fixed this by editing the reader on line 25 from: data = np.loadtxt(FID, delimiter=',') #changed 3/6/17 to loadtxt from genfromtxt; much faster to: data = np.genfromtxt(FID, delimiter=',') #changed 3/6/17 to loadtxt from genfromtxt; much faster

This issue also occurred when I used np.loadtxt to read a csv outside a CFM run. Not sure if this is an issue with my computer specifically or not. Thanks!

benhills commented 2 years ago

Running on Windows, correct?

GHOpenonic commented 2 years ago

Yep, running on Windows.

maximusjstevens commented 2 years ago

@GHOpenonic @benhills It sounds like this is an issue on your end. If you are saving the file from excel you might need to check the encoding - excel has numerous formats for save as csv - I think you want UTF-8. You can also check the .csv in a simple text editor to check for any special characters that have been inserted. Also ensure that the line endings do not include an extra comma. My recommendation is to generate input csv files using python.

I implemented loadtxt rather than genfromtxt some time ago because loadtxt was significantly faster - but it seems that genfromtxt is much better at dealing with csv nuances, so I will change the code to genfromtxt in a future release.