@@ -84,6 +84,7 @@ function gmtread(_fname::String; kwargs...)
8484 cmd = parse_common_opts (d, cmd, [:V_params :f ])[1 ]
8585 cmd, opt_bi = parse_bi (d, cmd)
8686 proggy = " read " # When reading an entire grid cube, this will change to 'grdinterpolate'
87+ doTimeCheck = true # By default check for time columns in text files
8788
8889 # Process these first so they may take precedence over defaults set below
8990 opt_T = add_opt (d, " " , " Tg" , [:grd :grid ])
@@ -103,11 +104,10 @@ function gmtread(_fname::String; kwargs...)
103104 if (opt_T == " " ) opt_T = add_opt (d, " " , " To" , [:ogr ]) end
104105
105106 ogr_layer:: Int32 = Int32 (0 ) # Used only with ogrread. Means by default read only the first layer
106- if ((_varname = find_in_dict (d, [:varname ])[1 ]) != = nothing ) # See if we have a nc varname / layer request
107- varname:: String = string (_varname)
107+ if ((varname = hlp_desnany_str (d, [:varname ])) != " " ) # See if we have a nc varname / layer request
108108 (opt_T == " " ) && (opt_T = " -Tg" ) # Though not used in if 'gdal', it still avoids going into needless tests below
109109 if (via_gdal || contains (varname, ' /' )) # This branch is fragile
110- fname = sneak_in_SUBDASETS (fname, varname) # Get the composed name (fname + subdaset and driver)
110+ fname = sneak_in_SUBDASETS (fname, varname) # Get the composed name (fname + subdaset and driver)
111111 proggy = " gdalread"
112112 gdopts:: String = " "
113113 if ((val1 = find_in_dict (d, [:layer :layers :band :bands ])[1 ]) != = nothing )
@@ -117,6 +117,7 @@ function gmtread(_fname::String; kwargs...)
117117 end
118118 else
119119 fname *= " ?" * varname
120+ doTimeCheck = false # We do not want to check for time columns in this case (would error out)
120121 if ((val = find_in_dict (d, [:layer :layers :band :bands ])[1 ]) != = nothing )
121122 if (isa (val, Real)) fname *= @sprintf (" [%d]" , val- 1 )
122123 elseif (isa (val, AbstractArray)) fname *= @sprintf (" [%d,%d]" , val[1 ]- 1 , val[2 ]- 1 ) # A 4D array
@@ -269,7 +270,7 @@ function gmtread(_fname::String; kwargs...)
269270 isa (o, Vector{<: GMTdataset }) && fish_attrib_in_header! (o)
270271
271272 # Try guess if ascii file has time columns and if yes leave trace of it in GMTdadaset metadata.
272- (opt_bi == " " && ! isISF && isa (o, GDtype)) && file_has_time! (fname, o, corder, opt_h)
273+ (doTimeCheck && opt_bi == " " && ! isISF && isa (o, GDtype)) && file_has_time! (fname, o, corder, opt_h)
273274
274275 # Function barrier to check if we should assign a default CPT to this grid and set the 'hasnans' field
275276 function check_set_default_cpt! (G:: GMTgrid , fname:: String )
0 commit comments