An automated algorithm for reliable equation of state fitting of magnetic systems