@@ -62,7 +62,10 @@ function VortexStepMethod.save_plot(fig, save_path, title; data_type=".pdf")
6262 @debug " Current working directory: $(pwd ()) "
6363
6464 try
65- fig. savefig (full_path)
65+ hasproperty (fig, :savefig ) || throw (ArgumentError (
66+ " Figure object of type $(typeof (fig)) does not support savefig()."
67+ ))
68+ getproperty (fig, :savefig )(full_path)
6669 @debug " Figure saved as $data_type "
6770
6871 if isfile (full_path)
@@ -658,20 +661,29 @@ function VortexStepMethod.plot_polars(
658661 # Load literature data if provided
659662 if ! isempty (literature_path_list)
660663 for path in literature_path_list
661- data = readdlm (path, ' ,' )
662- header = lowercase .(string .(data[1 , :]))
664+ raw_data = readdlm (path, ' ,' )
665+ table, header = if raw_data isa Tuple
666+ # readdlm(...; header=true) returns (data, header)
667+ raw_table, raw_header = raw_data
668+ raw_table, lowercase .(string .(vec (raw_header)))
669+ else
670+ # Header is in first row when a single matrix is returned
671+ raw_data[2 : end , :], lowercase .(string .(raw_data[1 , :]))
672+ end
663673 # Find column indices for alpha, CL, CD, CS (case-insensitive, allow common variants)
664674 alpha_idx = findfirst (x -> occursin (" alpha" , x) || x == " aoa" , header)
665675 cl_idx = findfirst (x -> occursin (" cl" , x), header)
666676 cd_idx = findfirst (x -> occursin (" cd" , x), header)
667677 cs_idx = findfirst (x -> occursin (" cs" , x), header)
678+ (isnothing (alpha_idx) || isnothing (cl_idx) || isnothing (cd_idx)) &&
679+ throw (ArgumentError (" Literature CSV must contain alpha/aoa, cl and cd columns: $path " ))
668680 # Fallback: if CS not found, fill with zeros
669- cs_col = cs_idx === nothing ? zeros (size (data , 1 )- 1 ) : data[ 2 : end , cs_idx]
681+ cs_col = cs_idx === nothing ? zeros (size (table , 1 )) : table[: , cs_idx]
670682 # Push as [alpha, CL, CD, CS]
671683 push! (polar_data_list, [
672- data[ 2 : end , alpha_idx],
673- data[ 2 : end , cl_idx],
674- data[ 2 : end , cd_idx],
684+ table[: , alpha_idx],
685+ table[: , cl_idx],
686+ table[: , cd_idx],
675687 cs_col
676688 ])
677689 end
0 commit comments