Weiming-Hu / AnalogsEnsemble

The C++ and R packages for parallel ensemble forecasts using Analog Ensemble
https://weiming-hu.github.io/AnalogsEnsemble/
MIT License
18 stars 5 forks source link

StationName order when using formatObservations #100

Closed map579 closed 4 years ago

map579 commented 4 years ago

When creating an observations list via the formatObservations function, the Station Names in the observations list output are not listed in ascending order. In my data (attached), 10-digit integers represent unique ambient air quality monitoring stations. When the observations list is created, three of the monitoring stations' IDs are out of order and included at the end of the list. The associated Xs and Ys coordinates in the last three positions are correct as they relate to the last three monitoring stations. I have formatted the monitoring stations' IDs as characters and integers, and the same three are out of order after running format Observations.

I am using the exact script from the help file example for formatObservations.

Thanks! - Mark obs15to18Final.zip

Weiming-Hu commented 4 years ago

Mark, I took a look at the code and this is indeed the case: observations are sorted based on any riteria.

Since it is desirable to have them sorted, I added an argument in this commit 4272228e5dbccbcb9c89d4f4d4d4c789919e232d. Please update your package and try it out.

map579 commented 4 years ago

Hi Weiming. I've updated the package and tried it twice, but formatObservations still results in the same 3 stations appearing at the end of the list, out of order (whether I declare the station IDs as characters or integers).

Weiming-Hu commented 4 years ago

Did you set the argument sort.stations?

map579 commented 4 years ago

Haha! You snuck in a new argument. :)

So I was missing the "s" on StationNames, as well. After adding the new argument and fixing the name of the column, the function is working as expected. I did some spot checks on the data and looks good. Thanks!