Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone Python Crayfish processing: Incorrect parameter value for CRAYFISH_INPUT_TIMESTEP #449

Open
maetal opened this issue Jun 2, 2020 · 6 comments
Labels
enhancement feedback more information needed or feedback requested

Comments

@maetal
Copy link

maetal commented Jun 2, 2020

I am trying to convert meshes to faces-polygons using a standalone python-script. I successfully added the CrayfishProcessingProvider to the progessingRegistry but I am unable to execute the algorithm.

  • The QualityMesh.shp can be created without problems using the Toolbox in QGIS
  • Afterwards I copied the code from the Processing history and added it to my standalone script.

Here the code snippet I am using:

meshfilepath='C:/Temp/Mesh.2dm'`
timestep=0
output='C:/Temp/QualityMesh.shp'

param = {'CRAYFISH_INPUT_LAYER':meshfilepath,
		 'CRAYFISH_INPUT_DATASETS':[],
		 'CRAYFISH_INPUT_TIMESTEP':timestep,
		 'OUTPUT':output}

feedback = QgsProcessingFeedback()
alg_name='crayfish:CrayfishExportMeshFaces'

res = processing.run(alg_name,param,feedback=feedback)
print(res)

The code crashed with the following error:

File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\Processing.py", line 137, in runAlgorithm
    raise QgsProcessingException(msg)
_core.QgsProcessingException: Unable to execute algorithm
Incorrect parameter value for CRAYFISH_INPUT_TIMESTEP

--> I get the same error running the code from the Processing-History it in the Python-Console in QGIS

When using the GUI-based Processing toolbox I get a Dropdown-List for "Timestep" where only one value is present: '0:00:00'.
grafik

I have tried various parameter values for CRAYFISH_INPUT_TIMESTEP, including int and str as it is mentioned in processing.algorithmHelp('crayfish:CrayfishExportMeshFaces')

What is the default/correct input value for CRAYFISH_INPUT_TIMESTEP?
Thank you and best regards!

@PeterPetrik
Copy link
Contributor

Timestep is QgsMeshDatasetIndex representing the index of group&time, you can look at the implementation around this

index = QgsMeshDatasetIndex(groupWithMaximumDatasets, i)

so you probably need QgsMeshDatasetIndex(0, 0) or so (for first dataset group and first timestep)

@maetal
Copy link
Author

maetal commented Jun 3, 2020

May I ask you to give some more details to what exactly should the CRAYFISH_INPUT_TIMESTEP value be, in the form of timestep= {0,0} ? I can't get the script to work with the given information above.

Thanks a lot!

@PeterPetrik
Copy link
Contributor

timestep=QgsMeshDatasetIndex(0, 0) ?

@maetal
Copy link
Author

maetal commented Jun 3, 2020

Unfortunately this does not work.
Code in the QGIS python console:

timestep=QgsMeshDatasetIndex(0, 0)

processing.run("crayfish:CrayfishExportMeshFaces", {'CRAYFISH_INPUT_LAYER':'C:/Temp/Mesh.2dm','CRAYFISH_INPUT_DATASETS':[],'CRAYFISH_INPUT_TIMESTEP':timestep,'OUTPUT':'C:/Temp/QualityMesh.shp'})

Error:

Traceback (most recent call last):
  File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\general.py", line 106, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\Processing.py", line 137, in runAlgorithm
    raise QgsProcessingException(msg)
_core.QgsProcessingException: Unable to execute algorithm
Incorrect parameter value for CRAYFISH_INPUT_TIMESTEP

@PeterPetrik
Copy link
Contributor

Thinking about it, the timestep parameter is only in the plugin and not natively supported in QGIS core. So maybe it does not work ATM from script.

we are planning to port the whole processing to QGIS, but we are looking for funds and time slot.

@saberraz
Copy link
Contributor

@maetal could you try again with the latest Crayfish and QGIS?

@saberraz saberraz added the feedback more information needed or feedback requested label Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feedback more information needed or feedback requested
Projects
None yet
Development

No branches or pull requests

3 participants